I got a little confused about objects when it comes to Strings, so I wanted to know how many objects would be created using the following code, with some explanation for creating String objects with respect to the string pool and heap.
public static void main(String[] args) {
String str1 = "String1";
String str2 = new String("String1");
String str3 = "String3";
String str4 = str2 + str3;
}
source
share