代码:
package uuu;
interface Animal{
void speak();
}
public class Test {
public static void main(String[] args) {
Animal m1=new Animal()
{
public void speak()
{
System.out.println("miao,miao...");
}
};
m1.speak();
Animal m2=new Animal()
{
public void speak()
{
System.out.println("Wang,Wang...");
}
};
m2.speak();
}
}
运行结果: