匿名内部类

public interface ICan{
    void eat();
}

public static void main(String[] args){

    //在代码量少,只需一个实例的时候就可以运用匿名内部类
    ICan ican = new ICan(){
        public void eat(){
            System.out.println("i can eat");
        }
    }
    
    
}
  1. 方便,快捷
原文地址:https://www.cnblogs.com/fiwen/p/9005377.html