匿名内部类

作用:有些类只使用一次

实现:

interface A{
  a();  
}

class Test(){

  public static  void test(A a){
    a.a();
 }  

  public static void main(Strnig args[]){
      A.test(new A(){
    a(){
        System.out.println("test once");  
    }
  });
  }  
}

 

posted on 2016-04-06 23:43  Simle  阅读(143)  评论(0编辑  收藏  举报