If I write something like this:
String s1 = new String("ABC");
String s2 = "ABC";
In which scenarios does the string pool get updated? The first, second or both?
In the above programming code ,when string pool get updated?
The first statement will update/add to the String pool with "ABC" String literal, but create another object in the heap and the variable s1 will refer the heap object.
The second statement will refer the already created Pool String object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With