Because everytime new value is assigned to string.. JVM takes care of creating new String object to hold that value..
On Tue, Aug 30, 2011 at 3: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 -- Thanks, Pawan. -- 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
