用戶名、密碼、日誌輸出等無處不在。Java 中字符串作為 java.lang.String 對象處理,該包默認自動導入。

String s = "Hello";(推薦,利用常量池)。String s = new String("Hello");(每次創建新對象)。new String(char[])、new String(byte[])。日常開發優先使用字面量;需頻繁修改字符串內容時,請使用 StringBuilder(單線程)或 StringBuffer(線程安全)。