public class Adventure extends Class1
implements Interface1,Interface2,Interface3{
public void fight1(){}
public void fight2(){}
public void fight3(){}
public static void main(String[] args){
Class1 a = new Adventure();
a.fight1();
}
}
interface Interface1{
void fight1();
}
interface Interface2{
void fight2();
}
interface Interface3{
void fight3();
}
class Class1{
void fight1(){System.out.println("fsadf");}
}
为什么打印为空,而不是fsadf
implements Interface1,Interface2,Interface3{
public void fight1(){}
public void fight2(){}
public void fight3(){}
public static void main(String[] args){
Class1 a = new Adventure();
a.fight1();
}
}
interface Interface1{
void fight1();
}
interface Interface2{
void fight2();
}
interface Interface3{
void fight3();
}
class Class1{
void fight1(){System.out.println("fsadf");}
}
为什么打印为空,而不是fsadf
另外:从你的代码来看,类Adventure中的fight1()是对接口Interface中的方法fight1()的实现,正规来说父类Class1最好也实现Interface(为可读性考虑)。