1.StringBuffer中delete和deleteCharAt两个方法的区别:
delete(int a,int b):删除下标a到b的值,包含a但不包含b
deleteCharAt(int a):只删除下标为a的值
注意:下标从0开始数
2.lambda表达式:Collectors.groupingBy(参数1),返回值为map(key,value),参数1对应key的值,value对应key下面的所有值。
如:List<Student> stus = new ArrayList<Student>();
Student stu1 = new Student(188,"xmd","a");
Student stu2 = new Student(188,"xmd","a");
Student stu3 = new Student(188,"xmd","b");
Student stu4= new Student(188,"xmd","b");
stus .add(stu1);
stus .add(stu2);
stus .add(stu3);
stus .add(stu4);
Map<String,LIst<Student>> map = stus.stream().collect(Collector.groupingBy(Student::getCode));
map的值为:
a:[Student{age=188, username='xmd', code='a'}, Student{age=188, username='xmd', code='a'}]
b:[Student{age=188, username='xmd', code='b'}, Student{age=188, username='xmd', code='b'}]
3.ApplicationContextAware作用
实现了ApplicationContextAware接口的类会自动调用setApplicationContext方法,实现了这个接口的bean,在容器初始化的时候,会自动的将ApplicationContext注入进来。