介绍
方法引用通过方法的名字来指向一个方法。
方法引用可以使语言的构造更紧凑简洁,减少冗余代码。
方法引用使用一对冒号 :: 。
使用::引用方法
结合foreach遍历list
。
List<StudentPo> studentPos = CreatList.creatList();
//::引用的方法入参与foreach遍历对象一样,引用静态方法如下
studentPos.forEach(CreatList::test);
//使用对象引用方法
CreatList creatList = new CreatList();
studentPos.forEach(creatList::noStatic);