Previous Lecture Lecture 8 Next Lecture

Lecture 8, Wed 10/23

Immutability of String in Java

Objects of type String in Java are immutable.

They cannot be changed after they are initially created.

So, if I write:

String name = "Phill";
name = name + "ip";

Now, name refers to a String “Phillip”.

No. String is still immutable.

How do we explain this?