ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories >> Software >> Java-Related >> Java-J2EE >> Core-Java
 
 
 
Question
When you say String is immutable, what do you mean by that?
Say I have String s = "Ness"
s= s+"Technologies";
What will happen? If the value gets appended, then what is
the meaning of immutable here?
 Question Submitted By :: Maria
I also faced this Question!!     Rank Answer Posted By  
 
Answer
Once you have assigned a value to a "String Object" (i am 
saying an "object" not the "object reference")that value 
can never change. This is immutability.

by defining "s = s+Technologies" we are pointing the 
REFERENCE to newly created "string object" with the 
modified string. So the previous string object is 
considered to be lost.

This concept has explained very well in String, I/Os 
chapter of Kethy Siera, SCJP 5.

All the best
 
0
Haribabu
 
View All Answers
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com