interface Animal{
void breathe();
void eat();
void sleep();
}
class Cat implements Animal{
@Override
public void breathe() {
System.out.println("一直在呼吸...");
}
@Override
public void eat() {
System.out.println("就知道吃吃吃!");
}
@Override
public void sleep() {
System.out.println("一天天的就知道睡!");
}
}
interface Bird extends Animal{
void fly();
}
interface Human extends Animal{
void speak();
void think();
}
class bird implements Bird{
@Override
public void fly() {
System.out.println("鸟的优点就是能上天吧");
}
@Override
public void breathe() {
}
@Override
public void eat() {
}
@Override
public void sleep() {
}
}
class man implements Human{
@Override
public void breathe() {
}
@Override
public void eat() {
System.out.println("人类的优势在于用筷子吃饭");
}
@Override
public void sleep() {
}
@Override
public void speak() {
System.out.println("Wow~ You can really dance~");
}
@Override
public void think() {
System.out.println("I think~");
}
}
public class main {
public static void main(String[] args) {
Cat cat = new Cat();
cat.breathe();
cat.eat();
cat.sleep();
man woman = new man();
woman.speak();
woman.think();
}
}
来源:CSDN
作者:Bangchui_programer
链接:https://blog.csdn.net/Bangchui_programer/article/details/103774125