interface Animal
{
void eat();
void sleep();
}class zoo
{
class tiger implements Animal
{
public void eat()
{
System.out.println("tiger eat");
}
public void sleep()
{
System.out.println("tiger sleep");
}
}
Animal Getanimal()
{
return new tiger();
}
}class Test
{
public static void main(String[] args)
{
zoo zo=new zoo();
Animal an=zo.Getanimal();
an.eat();
an.sleep();
}
}最下面Animal的声明,是接口的声明吗???谢!!!
{
void eat();
void sleep();
}class zoo
{
class tiger implements Animal
{
public void eat()
{
System.out.println("tiger eat");
}
public void sleep()
{
System.out.println("tiger sleep");
}
}
Animal Getanimal()
{
return new tiger();
}
}class Test
{
public static void main(String[] args)
{
zoo zo=new zoo();
Animal an=zo.Getanimal();
an.eat();
an.sleep();
}
}最下面Animal的声明,是接口的声明吗???谢!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货