I know this might be quite basic and probably pretty straight forward but i cannot clearly understand what will happen in this situation, so, here it goes.
In the following code:
String str1 = "Hello";
String str2 = "World";
String str3 = new String("HelloWorld");
String str4 = str1 + str2;
i know that str1 and str2 will create an object "Hello" and "World" respectively inside the String Constant Pool. While for str3 a new object is created outside the String Constant Pool which is pointing to "HelloWorld" that is created inside String Constant Pool.
My question is, what will happen if i concat 2 or more string (using '+' or concat() method)?
Will a new object be created outside the pool just like in the case of String str3 or will str4 point directly at the object "HelloWorld" inside the String Constant Pool
PS : And IF it is the case similar as creation of new object outside the pool, then how does it happen without using the new keyword?