Skip to content

Commit c69e8e3

Browse files
committed
add back missing string
add missing character add missing md formatting
1 parent 7bcff69 commit c69e8e3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/CH18.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public class DateTimeInstanceDemo2 {
214214
int monthConstant = rightNow.get(Calendar.MONTH);
215215
System.out.println(months[monthConstant]);
216216

217-
同樣的,如果您想要取得星期資訊,要記得 Calendar 的星期常數從星日 Calendar.SUNDAY 是 1,到星期六 Calendar.SATURDAY 是 7,由於對應的數並不是從0開始,所以如果要使用陣列來對應的話,第一個陣列的元素值就不包括資訊,例如:
217+
同樣的,如果您想要取得星期資訊,要記得 Calendar 的星期常數從星期日 Calendar.SUNDAY 是 1,到星期六 Calendar.SATURDAY 是 7,由於對應的數並不是從0開始,所以如果要使用陣列來對應的話,第一個陣列的元素值就不包括資訊,例如:
218218

219219
String[] dayOfWeek = {"", "日", "一", "二",
220220
"三", "四", "五", "六"};
@@ -372,6 +372,7 @@ public class LoggingDemo {
372372

373373
您簡單的透過 Logger 的靜態方法 getLogger() 取得 Logger 物件,給 getLogger() 的字串引數被用來作為 Logger 物件的名稱,之後就可以運用 Logger 實例上的方法進行訊息輸出,預設是從文字模式輸出訊息,除了您提供的文字訊息之外,Logger 還自動幫您收集了執行時相關的訊息,像是訊息輸出所在的類別與套件名稱,執行該段程式時的執行緒名稱以及訊息產生的時間等,這比下面這個程式所提供的訊息豐富的多了:
374374

375+
```java
375376
package onlyfun.caterpillar;
376377
public class LoggingDemo {
377378
public static void main(String[] args) {
@@ -383,6 +384,7 @@ public class LoggingDemo {
383384
}
384385
}
385386
}
387+
```
386388

387389
所以您不用親自實作日誌功能的程式,只要直接使用 java.util.logging 工具,就可以擁有一些預設的日誌功能,對於中大型系統來說,java.util.logging 套件下所提供的工具在功能上可能不足,但作為一個簡單的日誌工具,java.util.logging 套件下所提供的工具是可以考慮的方案。
388390

@@ -709,11 +711,13 @@ getParent() 方法可以取得 Logger 的上層父 Logger,根 logger 並沒有
709711

710712
在程式中有很多字串訊息會被寫死在程式中,如果您想要改變某個字串訊息,您必須修改程式碼然後重新編譯,例如簡單顯示 "Hello!World!" 的程式就是如此:
711713

714+
```java
712715
public class Hello {
713716
public static void main(String[] args) {
714717
System.out.println("Hello!World!");
715718
}
716719
}
720+
```
717721

718722
就這個程式來說,如果日後想要改變 "Hello!World!" 為 "Hello!Java!",您就要修改程式碼中的文字訊息並重新編譯。
719723

0 commit comments

Comments
 (0)