class Person{
public void eat(){
System.out.println("在吃饭..");
}
public void run(){
System.out.println("在跑..");
}
}
interface Dao{
public void add();
}
class Outer{
public void print(){
//继承关系下的匿名内部类
new Person(){
//匿名内部类的成员
public void sleep(){
System.out.println("在睡觉..");
}
}.eat();
}
//实现关系下的匿名内部类
public void show(){
//这里创建的不是Dao接口的对象,创建的是Dao接口实现类的对象。
new Dao(){
public void add(){
System.out.println("添加成功..");
}
}.add();
}
}
class Demo75
{
public static void main(String[] args)
{
Outer outer = new Outer();
outer.print();
outer.show();
}
}