整理 Effective Java 書中 Item 62: Avoid using strings when other types are more appropriate 心得筆記
主旨
String
很好用,但也很容易被濫用。因為輸入資料常常是文字格式,很多人會直接用 String
當作萬用資料型別──
但這會造成型別不清、錯誤率高、效能差,也難以維護。
本篇重點就是:不要把 String 當萬用型別。若有更合適的型別,就該使用更合適的型別。
整理 Effective Java 書中 Item 62: Avoid using strings when other types are more appropriate 心得筆記
String
很好用,但也很容易被濫用。因為輸入資料常常是文字格式,很多人會直接用 String
當作萬用資料型別──
但這會造成型別不清、錯誤率高、效能差,也難以維護。
本篇重點就是:不要把 String 當萬用型別。若有更合適的型別,就該使用更合適的型別。