Immutability of Strings in Java
Consider the following example. String str = new String(); str = “Hello”; System.out.println(str); //Prints Hello str = “Help!”; System.out.println(str); //Prints Help! Now, in Java, String objects are immutable. Then how come the object str can be assigned value “Help!”. Isn’t this contradicting the immutability of strings in Java? Can anybody please explain me the exact … Read more