There was a simple question around the Stringz instance pool in Java
If I have a situation like this: Scenario 1:
String s1 = "aaa";
String s2 = new String("aaa");
and then clicked Scenario 2:
String s1 = new String("aaa");
String s2 = "aaa";
In each case, how many objects are created in the row pool and heap? I assumed that both would create an equal number of objects (2 objects - one single "aaa" for both lines in each script in the string pool and one for the new statement). I was told in iview that this was wrong: I am curious what is wrong with my understanding?
source
share