interface ShowMessage{
void showTradeMark();
}
class TV implements ShowMessage{
public void showTradeMark(){
System.out.println("我是电视机");
}
}
class PC implements ShowMessage{
public void showTradeMark(){
System.out.println("我是电脑");
}
}
public class Example5_12{
public static void main(String arg[]){
ShowMessage sm;
sm=new TV();
sm.showTradeMark();
sm=new PC();
sm.showTradeMark();
}
}
interface Show{
void show();
}
class A implements Show{
public void show(){
System.out.println("I love This Game");
}
}
class B implements Show{
public void show(){
System.out.println("我喜欢看NBA");
}
}
class C{
public void f(Show s){
s.show();
}
}
public class Example5_13{
public static void main(String arg[]){
C c=new C();
c.f(new A());
c.f(new B());
}
}