@Test
public void jdk18(){
Demo d = new Demo();
System.out.println("-------1.8-新特新-------");
d.print();
Inter.method();
// Demo d = new Demo();
d.run();
}
}
interface Inter {
public default void print() {
System.out.println("Hello World");
}
public static void method() {
System.out.println("static method");
}
}
class Demo implements Inter {
public void run() {
int num = 10; //JDK8,前面的final可以省略
class Inner {
public void fun() {
System.out.println(num);
}
}
Inner i = new Inner();
i.fun();
}
}
原文:http://blog.51cto.com/357712148/2158384