interface Civilization extends Culture{
}
这句混淆了.
接口里面需要定义抽象方法,实现后,子类必须全部覆盖父类中,或者接口中的抽象方法.
class Animal{
public void eat(){System.out.println("I want to eat");}
public void sleep(){System.out.println("I want to sleep");}
private void die(){System.out.println("I maybe to die");}
}
class Culture {
public void think(){System.out.println("I can think");}
public void say(){System.out.println("I can speak");}
}
interface Civilization {
public abstract void wareness(){System.out.println("I know what is love");
}
public class Person extends Animal implements Civilization{
}
public static void main(String[] args){
Person ren=new Person();
ren.wareness();
ren.eat();
ren.say();
}
} |