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.测试:

JAVA8之方法引用

相关文章:

  • 2021-09-21
  • 2021-10-23
  • 2021-07-19
  • 2021-10-25
  • 2021-06-08
  • 2022-12-23
  • 2021-04-11
  • 2021-05-06
猜你喜欢
  • 2022-01-31
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2022-02-23
  • 2022-12-23
相关资源
相似解决方案