interface Person( public void eat(); ) public class Dome{ public static void main(String[] args){ Person p =new Person() { public void eat(){ System.out.println("something"); } };p.eat(); } }
以上为简单匿名类的写法 匿名内部类是内部类的一种特殊情况,其实是直接在类里面也方法。