My question is, what will happen if i concat 2 or more string (using '+' or concat() method)?
If you concat using + operator internally it will do like this:
new StringBuilder().append() .... /*appends correlated to your input*/ .toString()
and internally toString() will create a new object of String using new keyword. Because of that 2 object one in heap one in pool(if not exists) be created.
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
new object will be created. Becuase as explained above it will do new String(). But there will not be created any object in pool in case of str4.
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?
Internally use new