[Solved] Java Strings are immutable? [duplicate]

[ad_1]

The object itself didn’t change.

What you have done is the following

name <- String("Paul")
name <- String("Henry")

String(“Paul”) has been not been changed.

Try the following:

String a = "test";
String b = a;
a = "test2";

System.out.println(b);

[ad_2]

solved Java Strings are immutable? [duplicate]