package a; interface Animal{ int ID =1; String NAME="牧羊犬"; void shout(); static int getId(){ return Animal.ID; } public void info(); } interface Action{ public void eat(); } class Dog implements Animal,Action{ public void eat(){ System.out.println("喜欢吃骨头"); } public void shout(){ System.out.println("汪汪....."); } public void info(){ System.out.println("名称"+NAME); } } class Example11{ public static void main(String[] args) { System.out.println("编号"+Animal.getId()); Dog dog=new Dog(); dog.info(); dog.shout(); dog.eat(); }}
4-11 666666
最新推荐文章于 2024-11-05 19:36:08 发布