Immutable String

String str=“hello”;
str=“hello”+‘y’;

this code is working but strings are immutable. how it works.
if it works then please explain it and show me an example of immutable string.