大家來幫我看下什么問題
interface?Inter?{
public?static?final?int?NUM?=?3;
public?abstract?void?show();
}
interface?Inter1{
public?abstract?void?show();
}
?class?Test?implements?Inter,Inter1{
?public?void?show()?{
?System.out.println("多繼承方法被覆蓋!");
}
?}
public?class?InterfaDemo?{
public?static?void?main(String[]?args)?{
Test?t=new?Test();
System.out.println(t.NUM);
System.out.println(Test.NUM);
System.out.println(Inter.NUM);
System.out.println(t.show());
}
}為什么System.out.println(t.show());這一段報錯啊
2016-12-21
public?class?InterfaDemo?{ ? ????public?static?void?main(String[]?args)?{ ????????Test?t=new?Test(); ????????System.out.println(t.NUM); ????????System.out.println(Test.NUM); ????????System.out.println(Inter.NUM); ????????/*System.out.println(*/t.show()/*)*/; ????????//直接使用t.show();就可以打印了,void方法沒有返回值無法打印 ???????? ????} ? }2016-12-18
是語法問題吧,println不能打印返回值為空的方法