In your example you have reused variable to point to two different String objects. When we say String is immutable, the String Object is immutable.
On Aug 30, 2:07 pm, VM <[email protected]> wrote: > Why is String considered immutable while the code below works? > > String name = "Sang"; System.out.println(name); > name ="Shin"; > System.out.println(name); -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en
