亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

大家來幫我看下什么問題

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());這一段報錯啊

正在回答

2 回答

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方法沒有返回值無法打印
????????
????}
?
}


1 回復 有任何疑惑可以回復我~
#1

慕粉2333013499 提問者

非常感謝!
2016-12-21 回復 有任何疑惑可以回復我~

是語法問題吧,println不能打印返回值為空的方法

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

大家來幫我看下什么問題

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號