在最初沒有理解和熟悉編寫類時,能夠說是一臉懵逼,「這些setXXXX()
,和getXXXX()
究竟是幹什麼的,return
是返回,那返回和輸出的區別是什麼,private
以前也從未見過。如何去解決呢?看例題、敲例題,當本身作完以後,研究輸出結果,對照程序自己,就能理解其含義了。
這些程序比以前的要長得多,但例題好歹也是通常的JAVA語言,都能看懂。html
問題1:PP4.7,找不到對象,如圖,java
問題1解決方案:輸入String類參數時,應加雙引號""
!git
問題2:例題4.1運行不了(找不到或沒法加載主類 Die),如圖,程序員
package week4
打包,在其前加上//
變爲註釋無效化便可。問題3:PP7.3編譯錯誤*1,如圖,編程
javac -Xlint:unchecked XXX
進行檢查,發現建立名爲Student的ArrayList時,沒有肯定保存對象的數據類型致使錯誤,加入後建立:ArrayList<student> Student = new ArrayList<student>()
,問題解決。問題4:PP7.3運行錯誤*1,如圖,數據結構
問題4解決方案:檢查命令行提供的信息找到錯誤出處,發現關鍵函數
public float average() {學習
int i = 0; Sum = 0; while (i <= ScoreList.size()){ Sum += ScoreList.get(i); i += 1; } sum = Sum; AverageScore = sum / StudengtList.size(); return AverageScore;
循環語句中i <= ScoreList.size()
出了問題(i不能等於size,而是size-1),致使Sum += ......
沒法正常進行。改成i < ScoreList.size()
後問題解決。測試
(statistics.sh腳本的運行結果截圖)ui
錯題1: The behavior of an object is defined by the object's
正確答案:method
錯誤緣由:想固然認爲全部因素都影響着對象的行爲,然而全部行爲確實歸根結底都是方法決定的;
錯題2:All Java classes must contain a main method which is the first method executed when the Java class is called upon.
正確答案:false
緣由:只有驅動類才須要main方法,只有驅動類才須要main方法,只有驅動類才須要main方法。
錯題3:Every class definition must include a constructor.
正確答案:false
緣由:能夠沒有構造函數。
錯題4:During program development, software requirements specify
正確答案:what the task is that the program must perform
緣由:純粹的英語很差,沒讀懂題意,這道題根本就是一道英語題。
錯題5:The goal of testing is to
正確答案:find logical and run-time errors
緣由: 測試的目的是找到邏輯錯誤和運行錯誤,而語法錯誤是不須要從這裏找的,由於javac的時候就發現了。
錯題6:Interface classes cannot be extended but classes that implement interfaces can be extended.
正確答案:false
緣由:徹底能夠擴展。。。。
錯題7:All objects implement Comparable.
正確答案:false
緣由:只有實現了接口(定義compareTo方法),才能comparable。
代碼行數(新增/累積) | 博客量(新增/累積) | 學習時間(新增/累積) | 重要成長 | |
---|---|---|---|---|
目標 | 5000行 | 30篇 | 400小時 | |
第一週 | 195/195 | 1/4 | 20/20 | 對代碼產生了很大興趣 |
第二週 | 309/504 | 1/5 | 20/40 | 打字速度明顯提高 |
第三週 | 311/815 | 2/7 | 25/65 | 無 |
第四周 | 474/1289 | 1/8 | 30/95 | 抗...抗壓能力增強? |