According to "Java 2 A Beginner's Guide" by Herbert Schildt, Strings are immutable, i.e., once created you can't change them. However, I am playing in Eclipse and noticed that the following does in fact work:
String str = new String("Foo");
str = "Bar";
And the output is:
I had expected this to fail if a String is immutable. And yet I was able to change a String object (str) that initially held "Foo" to subsequently hold "Bar". Any ideas why this works?