String

String String s=「1231」; String s2=「1231」 s和s2都保存了方法區常量池中的「1231」的內存地址 所以== 爲true String s= new String(「123」); String s1=new String(「123」); 一共創建三個對象,常量池中有一個"123",堆內存地址中分別有兩個「123」對象 所以== 爲false,但是由於Strin
相關文章
相關標籤/搜索