Skip to content

add back missing string #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 15, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/CH18.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public class DateTimeInstanceDemo2 {
int monthConstant = rightNow.get(Calendar.MONTH);
System.out.println(months[monthConstant]);

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

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

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

```java
package onlyfun.caterpillar;
public class LoggingDemo {
public static void main(String[] args) {
Expand All @@ -383,6 +384,7 @@ public class LoggingDemo {
}
}
}
```

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

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

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

```java
public class Hello {
public static void main(String[] args) {
System.out.println("Hello!World!");
}
}
```

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

Expand Down