Whenever we make a String object by doing some operation on the Strings then we will always end up with new String Object.
String class has overridden hashCode() and equals() method so meaningfully the String objects may be equal and they will return the same hash code but then also they are situated at different memory location in the Objcet heap.
The default implementation of hashCode() provided by Object is derived by mapping the memory address of the object to an integer value. Because on some architectures the address space is larger than the range of values for int, it is possible that two distinct objects could have the same hashCode(). If you override hashCode(), you can still use the System.identityHashCode() method to access this default value. src The following example which I prepared by altering the above question will simplify my point.
The output of the above code is
So it is visible that whenever we make some String object by doing some alteration we will always end up in a new Object in heap. So the system HashCode will be different for them as no two Objects can share the same memory.
The hashcodes we get from the String Objects return the hashcode generated by this function as it is overridden in String class.
To get the actaul hashcode we used the static function
identityHashCode() of System class.
The system hashcode for str1 and str2 are same as those objects were created without any alteration on any of the objects.