public class Example42 {
public static void main(String[] args) {
Dog dog = new Dog();
Animal an = (Animal)dog;
Action ac = (Action)dog;
an.info();
an.shout();
ac.eat();
}
}
interface Animal {
int id = 1;
String name = "牧羊犬";
void shout();
void info();
static int getId(){
return id;
}
}
interface Action {
public void eat();
}
class Dog implements Animal,Action {
public void shout(){
System.out.println("汪汪叫");
}
public void info(){
System.out.println(Animal.name);
}
public void eat(){
System.out.println("吃狗粮");
}
}