Aneek Banerjee wrote:
Jeanne Boyarsky wrote:They are both string literals. I don't understand what you are asking.
I mean to ask will these create a new String object in the heap?
Yes "abc" and "abc1" are different. So there'll be two String literals in the heap, i.e "abc" and "abc1"
Had it been like this:
String s = "abc";
String s1 = "abc";
Java heap will only have 1 String literal, i.e "abc"