String s1="abc"; //line 1
String s2 = new String ("abc"); //line 2
String s3 = "abc"; //line 3
String s4 = s1+s2+s3; //line 4
I need to know how many objects are created in total.(Heap and SCP area).
At line 1, one object "abc" in SCP
At line 2, one object "abc" in heap
At line 3, s3 points already existing object "abc" in SCP
Till this point there are 2 objects. I am not able to figure out exactly how many after line 4. Is there a way to find out how many objects are created in these cases using a java program?