1 匿名内部类笔试

package Test;
//要求在控制台输出helloworld
public class NoNameClassTest {
   public static void main(String[] args) {
       //链式编程,每次调用方法后还能继续调用,证明返回的方法是对象
      Outer.method().show();
      //method静态,method方法返回的是对象
  }
}
interface Inter{    
void show();
}
class Outer{ //补齐代码 public static Inter method(){ //返回Inter的子类对象 return new Inter(){ @Override public void show() { System.out.println("hello world"); } }; } }



猜你喜欢

转载自www.cnblogs.com/ltfxy/p/10091440.html