public interface Animal {
int BIG_TYPE=5;
void sleep();
void eat();
void breath();
}
//Tiger.java实现接口的方法
public class Tiger implements Animal
{
public void sleep{
System.out.println("the tiger sleep");
}
public void eat{
System.out.println("the tiger eat");
}
public void breath{
System.out.println("the tiger breath");
}
}
//测试类test.java
public class test {
public static void main(String[] args){
Tiger tiger=new Tiger();
tiger.sleep();
tiger.eat();
tiger.breath();
}
}
运行test.java出现错误
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method sleep() is undefined for the type Tiger
The method eat() is undefined for the type Tiger
The method breath() is undefined for the type Tiger