lambda表达式新特性--方法引用
1.对象::实例方法名
2.类名::静态方法名
3.类名::实例方法名
public class TestInstanceReference {
public static void main(String[] args) {
TestInstanceReference test = new TestInstanceReference();
User user = new User("欧阳峰",32);
Supplier<String> supplier = () -> user.getName();
System.out.println("Lambda表达式输出结果:" + supplier.get());
Supplier<String> supplier2 = user::getName;
System.out.println("实例方法引用输出结果:" + supplier2.get());
}
}