public interface PeopleDemo {
void play();
}
class man implements PeopleDemo {
@Override
public void play() {
System.out.println("弹琴~~");
}
}
class woman implements PeopleDemo {
@Override
public void play() {
System.out.println("唱歌");
}
}
//通过test中一个方法来实现各个实现类的功能(利用传参)
class test {
public static void show(PeopleDemo demo){
demo.play();
}
public static void main(String[] args) {
PeopleDemo demo1 = new man();
PeopleDemo demo2 = new woman();
test.show(demo1);
test.show(demo2);
}
}