JAVA8之方法引用
1.编码
public class MethodRef { @FunctionalInterface public interface Func<T> { void func(T t); } void fun(Func<String> fun, String a) { fun.func(a); } void sysHello(String s) { System.out.println(s); } void test() { fun(this::sysHello, "hello Java!"); } public static void main(String[] args) { MethodRef demo = new MethodRef(); demo.test(); } }
2.测试: