Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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?

Answer Posted / haribabu

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

Is This Answer Correct ?    26 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is dynamic binding(late binding)?

1051


Why do we need autoboxing in java?

999


What is the use of a conditional inclusion statement in Java ?

1095


Is array an object in java?

967


Can we serialize static variables in java?

1098


What is update method called?

1161


Why do we need variables?

990


What is valid keyword in java?

1002


What is tostring () method?

1035


How does list work in java?

920


When should I use singleton?

1041


Name the components that are termed to be Heavy-weight component but available in Light-weight components?

2491


What is a “stateless” protocol ?

993


Describe method overriding

1129


What is hashing principle in java?

1028