只有new是在堆中产生对象
String s1 = "abc" //在栈里
String s2 = "abc" //s2和s1同时指向栈里的"abc"
你上面的结果是
str1 != str2
str2 == str3
要看本质,不要记所谓的规则。
String s1 = "abc" //在栈里
String s2 = "abc" //s2和s1同时指向栈里的"abc"
你上面的结果是
str1 != str2
str2 == str3
要看本质,不要记所谓的规则。

Fight to win or die...