How many String objects are created by the following code?
String x = new String(\"xyz\");
String y = \"abc\";
x = x + y;
I have visited ma
I would say 4 because:
Here's how:
String x = new String("xyz"); // 2 objects created: the variable and the constant
String y = "abc"; // 1 object created: the variable
x = x + y; // 1 object created: the one by the StringBuilder class