Head First Java中placeDotCom()出錯的解決

今天又重回HFJ,上次退出時沒解決的問題解決了,其實是很小的問題,記錄如下:

在Chapter6中,對上一章的dotcom遊戲進行改進,書中源碼輸入後,

for(DotCom dotComToSet :dotComsList){
        ArrayList<String> newLocation=helper.placeDotCom(3);
        //ArrayList<String> newLocation =helper.placeDotCom(3);
        dotComToSet.setLocationCells(newLocation);
    }

提示DotComBust.java中有錯誤:The method placeDotCom(int) is undefined for the type GameHelper,即GameHelper類中的方法placeDotCom()沒定義。


查了一圈,後來發現鼠標停在helper上有提示框

wKioL1hBTu2TMJD0AAAt0dDEt80910.png-wh_50

我每個章節的代碼放在不同的chaper包裏,但是全在HFJ的project下,這個help識別到chapter5中的同名GameHelper中了。

更改類名即可解決。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章