Its true that in Java String are immutable. Even in the code given its
immutable.. Its actually the code executed like this..

String s="java"; // S holds to java.
        s+="c c++"; //

 Here S = S + "c c++"
           "Java" + "c c++"  which is now assigned to the new variable which
here is s itself.

 So S is evaluated first so its java and then concatenated and then finally
assigned to variable.





On Fri, Aug 26, 2011 at 12:16 PM, tech coder <techcoderonw...@gmail.com>wrote:

> in java a tring object is immutable
>
> but in following code
>
>   String s="java";
>         s+="c c++";
>         System.out.print(s);
>
> the output is " javac c++"
>
> why this is so
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to