為什么我的大括號總是錯!
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("使用匿名內部類的方式");
???}
???
??}
?}
}
?
2016-08-21
你最后漏了一句ip3.playGame();?
你必須要通過 對象名ip3 把你的playGame方法里的內容 輸出出來
2015-06-21
};然后沒有錯了,運行結果為
通過鍵盤打電話!
通過鍵盤發短信!
通過語音打電話!
通過語音發短信!
具有了玩游戲的功能!
具有了玩游戲的功能!
為什么最后一句沒有輸出!使用匿名內部類的方式,這個沒有輸出!