日期:2014-05-20  浏览次数:20548 次

求救 编译时说无法实现接口中的方法
下面的片全部代码是在一个名叫tt2.java的文件里面
interface animal
{
public void eat();
}

interface fly
{
public void fly();
}

class bird implements animal,fly
{
void eat()
{
System.out.printf("I am eating");
}
void fly()
{
System.out.printf("I can fly");
}
}

public class tt2
{
public static void main(String args[])
{
bird a=new bird();
a.eat();
a.fly();
}
}

然后编译的时候出现错误

错误: bird中的eat()无法实现animal中的eat()  
void eat()
  ^
  正在尝试分配更低的访问权限; 以前为public
错误: bird中的fly()无法实现fly中的fly()
  void fly()
  ^
  正在尝试分配更低的访问权限; 以前为public

求大神门解救啊

------解决方案--------------------
Java code

class bird implements animal, fly {
    public void eat() {
        System.out.printf("I am eating");
    }

    public void fly() {
        System.out.printf("I can fly");
    }
}