看板 java 關於我們 聯絡資訊
想請教一下, String x = "hello"; String y = "hello"; System.out.println( x==y); 電腦輸出 true 為何會這樣呢?! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 124.8.148.178
lui:因為"hello"在string pool裡 x, y都指向它 01/19 23:49
chchwy:因為字串比較不能用== 01/19 23:50
james732:字串比較不是不能用==,只是這個動作符不符合需求 01/19 23:51
slalala:月經題出現囉 01/20 00:56
kavana999:請教一下,不然你覺得應該是怎樣... 01/20 20:09
solomn:月經題還是可以發問吧,本來就永遠都會有初學者呀 01/21 16:20
slalala:看一下下一篇回應 google一下就找到了 01/21 21:54
bemyself:一樓正解^.^ 01/22 22:52
henry761128:用 new 生出來的話才會不一樣喔 01/23 00:07
wunming:因為x==y是判斷式 02/10 18:01