mercredi 1 avril 2015

Counting String objects created by Java code

How many String objects have been created by the following code?



String x = new String("xyz");
String y = "abc";
x = x + y;


I have seen on another site some say that this line of code creates a 3 objects and some says this line of code create a 4 objects. So let me know how many objects created after this line of code executes.


Aucun commentaire:

Enregistrer un commentaire