Java 中指向 String 方法的函数指针
我不明白lambda的几件事。
String s = "Hello World";
Function<Integer, String> f = s::substring;
s = null;
System.out.println(f.apply(5));
如果 出现 ,为什么该方法仍然有效。毕竟,GC 应删除该对象,因为没有指向该对象的指针。f.apply
s = null
String
还有一件事,为什么我在这里不需要退货声明?
Function<Integer, String> f = t -> t + "";