package test;
interface Inter {
void show();
}
class Outer {
static class Inner implements Inter {
public void show() {
System.out.println("hello");
}
}
public static Inner function() {
return new Inner();
}
}
public class InnerClassDemo {
public static void main(String[] args) {
Outer.function().show();
}
}
化简代码
package test;
interface Inter {
void show();
}
class Outer {
public static Inter function() {
return new Inter() {
public void show() {
System.out.println("hello");
}
};
}
}
public class InnerClassDemo {
public static void main(String[] args) {
Outer.function().show();
}
}