String str ="abc"; // 1
str.toUpperCase(); // 2
System.out.println(str); // 3
in above code
First line will create new Object of String with value "abc" and assign it to the reference variable str.
Second line will create the new Object of String because String class is immutable so original Object str will not change. but here we are not assigning the new object which is created in line 2 so it will be lost somewhere in Heap area.
That is why in line 3 printing value is "abc".
if you want to use the new Object created by str.toUpperCase() than have to assign that in a new reference variable.
or
alternative option is update the original String Object like this
str = str.toUpperCase();
but in above operation, the original Object str containing the value "abc" will be lost in the Heap area !!!!!
You can find details about working with String by example here.
str=str.toUpperCase();This has nothing to do with string pools.