interface Animal
{
void eat();
}
class zoo
{
Animal GetAnimal()
{
return new Animal()
{
public void eat()
{
System.out.println("animal eat");
}
};
}
}
class Test
{
public static void main(String []args)
{
zoo z=new zoo();
Animal an=z.GetAnimal();
an.eat();
}
}
时间: 2024-09-21 05:06:13