为什么这段代码不能编译?无法完全掌握 java 方法参考的细微差别:(
public class TestClass {
static void println() {}
public static void main(String[] args) {
Runnable r1 = () -> System.out::println; // compilation error
Runnable r2 = () -> TestClass::println; // compilation error
Runnable r2 = () -> System.out.println("Hello World"); // This is fine !!
}
}
Run Code Online (Sandbox Code Playgroud)