public interface ICan{
void eat();
}
public static void main(String[] args){
//在代码量少,只需一个实例的时候就可以运用匿名内部类
ICan ican = new ICan(){
public void eat(){
System.out.println("i can eat");
}
}
}
- 方便,快捷