匿名内部类的面试题
class Test02_NoNameInnerClass{
public static void main(String[] args){
//链式编程,每次调用方法后还能继续调用方法,证明调用方法返回的是对象
//Outer.method().show();
Inter i = Outer.method();
i.show();
}
}
//按照要求,补齐代码
//要求在控制台输出“HelloWorld”
interface Inner{
void show();
}
class Outer{
//补齐代码
public static Inner method(){
return new Inner(){
public void show(){
System.out.println("HelloWorld");
}
};
}
}