接口中方法的调用,搞不懂,诚恳的请教
interface CallBack{void callMethod();
}
interface CallBack1{
void callMethod1();
}
interface CallBack2{
void callMethod2();
}
class Client implements CallBack,CallBack1,CallBack2{
public void callMethod(){
System.out.println("hello");
}
public void callMethod1(){
System.out.println("hello1");
}
public void callMethod2(){
System.out.println("hello2");
}
}
public class huxiang{
public static void callMethod(CallBack someone){//这个叫不叫方法的重写啊,怎么感觉是多余的呢
someone.callMethod(); //把这三个静态方法去掉看上去没什么问题啊,怎么却不
} //能运行啊?请教了
public static void callMethod1(CallBack1 someone){
someone.callMethod1();
}
public static void callMethod2(CallBack2 someone){
someone.callMethod2();
}
public static void main(String args[]){
Client a=new Client();
callMethod(a);
callMethod1(a);
callMethod2(a);
}
}