標籤:使用 The stream dia 含義 integer over 另一個 mst
20172306《Java程式設計》第九周學習總結教材學習內容總結
第十一章:
- try-catch語句。其中還有finally語句。try是進行某些操作,catch是捕獲異常,並通過某些異常來進行某些操作。finally是無論是否有異常都會進行的語句。可以沒有catch語句。
- 異常的傳遞。我覺得傳遞,主要是某地方的異常是由其他的方法引起的,異常就會傳遞到那個方法上。書中的例子可以很好的表現出來。
- IO異常。書中的內容主要是圍繞異常來寫。老師在藍墨雲中有寫有關IO更為詳細的內容。例如建立檔案,寫入檔案,讀取檔案等等。
第十二章:
- 遞迴和迴圈是差不多的但是還是有不同的。對於死迴圈和死遞迴,死迴圈會一直迴圈運行,而死遞迴會出現溢出。因為空白間是有限的。
- 通過迷宮旅行和漢諾塔問題的模型,我個人學習到的是,考慮問題需要詳細一些。具體的代碼如何編寫,我認為更重要的是理解它是如何進行操作的。
教材學習中的問題和解決過程
- 問題1:什麼是方法呼叫堆疊蹤跡?
-
問題1解決方案:我上網查了一下。
- 問題2:對於eg11.2中一行代碼:district = Integer.parseInt(code.substring(3,7));中(3,7)不明白是多少到多少?
-
問題2解決方案:利用IDEA可以看到,substring(begineIndex,endIndex);我又問了同學,知道了這個應該是索引3,4,5,6。沒有7。
- 問題3:
-
問題3解決方案:最開始沒有理解它start,end,temp的含義。後來問了同學,加上自己的理解。知道其實這個方法,就是我們平時的時候,通過不斷調用的另一個柱子以實現從大到小的排列的這麼一個過程。
代碼調試中的問題和解決過程
-
問題1:在進行課後的實驗的時候,有這樣的問題,不知道是為什麼
-
問題1解決方案:原來是在IDEA中,我應用了中文,那麼我就應該,從而可以應用中文。
-
問題2:在做PP12.1時,最開始我想的是根據書中的迷宮旅行的代碼的樣式,對第五章的Tester進行改造。,但是結果卻是錯誤的。即使是用書中的例子abracadabra,結果出來也是IS而實際應該是NOT
- 問題2解決方案:最開始我想的是,是不是我的條件出現了錯誤。我進行了略微調整,發現依舊是錯的。後來我在想,這個不通,可不可以看看嘗試一下漢諾塔的那個模型,後來用了另一種方式成功了。
-
問題3:在做PP12.9的習題時,花費了很久的時間。最開始我找不到它的邏輯。後來想到可以按照行和列的數組的形式。我就在書中寫了這個,然後編了一個遞迴的類。但是出現了這個問題
- 問題3解決方案:我上網查了一下,這個意思就是棧溢出,說明我的運算式不夠最佳化。所以又進行了修改。
-
問題4:還是對於PP12.9的問題。我可以運行了,但是結果是 我就改了一下,但是又變成了
-
問題4解決方案:本來我就打算就這樣吧,後來還是問了一下同學,才知道我應該怎麼改,然後得到了合格結果
代碼託管
上周考試錯題總結
- A finally clause will execute
A only if the try statement that precedes it does not throw an exception
B only if the try statement that precedes it throws an exception that is caught
C only if the try statement that precedes it throws an exception that is not caught
D only if the try statement that precedes it throws an exception, whether it is caught or not
E in any circumstance 本題選E ,這題是我的馬虎。finally會在任何情況下都會執行。
- The Scanner class provides an abstraction for input operations by Scanner類為輸入操作提供了一個抽象
A using try and catch statements to catch any IOException instead of throwing the Exception elsewhere(使用try和catch語句捕捉任何IOException,而不是將異常拋出其他地方)
B parsing input lines into individual tokens(將輸入行解析為單個記號)
C performing conversion operations from String to the appropriate type as specified in the Scanner message(在掃描訊息中指定的從字串到適當類型的轉換操作)
D inputting from the standard input stream if create is called using System.in(如果建立的調用是使用系統的那麼從標準輸入資料流中輸入。)
E all of the above 本題選E
- The term "exception propagation" means
A an exception is caught by the first catch clause
B an exception not caught by the first catch clause is caught by an outer (enclosing) catch clause(不被第一個catch子句捕獲的異常被一個外部(封閉的)catch子句捕獲)
C exceptions are caught, sequentially, by catch clauses in the current try block
D exceptions always are caught by the outermost try block(異常總是被最外層的try塊捕獲)
E none of the above 本題選E
- A method that uses the Scanner class to obtain input does not require either catching or throwing an IOException. This is because
A the Scanner class does not call upon any classes that throw checked exceptions
B the Scanner class‘ methods call input methods in try statements and catch IOExceptions so that they are handled directly in the Scanner class
C the Scanner class uses JOptionPane dialog boxes instead of java.io classes so that it does not have to deal with IOExceptions
D the Scanner class overrides the class IOException making it an unchecked exception
E none of the above, methods do require handling IOException even if thrown by a method in a Scanner class 本題選B
- The following defines a new Exception called AnewException.
public Exception ANewException
{
public ANewException(String message)
{
super(message);
}
}
A true
B false 本題選B 它應該定義的是一個類,而不應該是Exception.
- If an exception arises in a catch statement, and the exception is of the type caught by the catch statement, then the catch statement catches the same exception. For instance, if the following catch statement first catches an ArithmeticException and, while executing, throws another ArithmeticException, it is able to catch the second ArithmeticException as well the first.
catch (ArithmeticException ex) {...}
A true
B false 本題選B 一個exception導致當前語句停止執行和控制轉移到第一個捕獲(在當前語句之後)的轉移,從而捕獲異常。因此,catch語句不會捕捉從自身內部拋出的異常,儘管catch語句可以嵌套在它的內部附加嘗試和捕獲語句。
- The difference between the throw reserved word and the throws reserved word is that throw is used within a method body, while throws is used within a method header.
A true
B false 本題選A,這個主要是throws和throw的區分。
結對及互評點評模板:
點評過的同學部落格和代碼
其他
這兩章是在老師講了之後我才去看的。基本是看得懂的。但是老師說對於IO異常這個方面,更需要瞭解的是如何利用流進行讀寫檔案等。這個方面我覺得我還不是很會,所以之後還會繼續學習這個。而十二章,我覺得對於我來說,重點就是要瞭解它每一步的操作,因為我覺得書中的遞迴的代碼寫的十分的縝密,這個方面我也不擅長,就在編寫後面的題時就可能想少東西,導致結果有問題。還需要學習。
學習進度條
|
程式碼數(新增/累積) |
部落格量(新增/累積) |
學習時間(新增/累積) |
重要成長 |
| 目標 |
5000行 |
30篇 |
400小時 |
|
| 第一周 |
193/200 |
1/1 |
20/20 |
|
| 第二周 |
247/440 |
1/1 |
22/42 |
|
| 第三周 |
445/895 |
2/2 |
20/62 |
|
| 第四周 |
885/1780 |
1/1 |
43/105 |
|
| 第五周 |
775/2555 |
1/1 |
55 /160 |
|
| 第六周 |
1171/3726 |
1/1 |
38/198 |
|
| 第七周 |
596/4322 |
1/1 |
60/258 |
|
| 第八周 |
569/4891 |
2/2 |
55 /313 |
|
| 第九周 |
1890/ 6781 |
1/1 |
66/379 |
|
參考資料
-
Java學習筆記(第8版)
-
《Java學習筆記(第8版)》學習指導
20172306《Java程式設計與資料結構》第九周學習總結