//接口应用实例 ,
//应该将类和接口放在哪里?谢谢~~
interface StartStop{//定义StartStop接口
void start();
void stop();
}
class Conference implements StartStop{//会议实现StartStop接口
public void start(){
System.out.println("Start the conference!");
}
public void start(){
System.out.println("Start the conference!");
}
}
class Car implements StartStop{//汽车实现StartStop接口
public void start(){
System.out.println("Start the car");
}
public void start(){
System.out.println("Start the car");
}
}
public class TestInterface{
public static viod main(String[] args){
StartStop[] ss={new Conference(),new Car()};
for(int i=0;i<ss.length;i++){
ss[i].start();
ss[i].stop();
}
}
}
[此贴子已经被作者于2007-11-18 10:15:07编辑过]