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

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

為什么我的大括號總是錯!

package interfacetest;

public class TelphoneTest {
?public static void main(String[] args) {
??Telephone tel1 = new CellPhone();
??tel1.call();
??tel1.message();
??Telephone tel2 = new SmartPhone();
??tel2.call();
??tel2.message();
??
??
??IPlayGame ip1 = new SmartPhone();
??ip1.PlayGame();
??IPlayGame ip2 = new Psp();
??ip2.PlayGame();
??
??IPlayGame ip3 = new IPlayGame(){

???@Override
???public void PlayGame() {
????// TODO Auto-generated method stub
???System.out.println("使用匿名內部類的方式");
???}
???
??}
?}
}


?

正在回答

2 回答

你最后漏了一句ip3.playGame();?

你必須要通過 對象名ip3 把你的playGame方法里的內容 輸出出來

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

};然后沒有錯了,運行結果為

通過鍵盤打電話!
通過鍵盤發短信!
通過語音打電話!
通過語音發短信!
具有了玩游戲的功能!
具有了玩游戲的功能!
為什么最后一句沒有輸出!使用匿名內部類的方式,這個沒有輸出!

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

舉報

0/150
提交
取消

為什么我的大括號總是錯!

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

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

幫助反饋 APP下載

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

公眾號

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