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 are the characteristics of java?

981


Write a program to print fibonacci series

1074


What is meant by call by reference?

947


In a container there are 5 components. I want to display all the component names, how will you do that?

2137


Explain the term virtual machine?

984


Explain inner classes ?

1072


List primitive java types?

978


How to disable caching on back button of the browser?

1004


What does provide mean construction?

1052


How to perform bubble sort in java?

949


What does singleton mean in java?

947


Can we sort set in java?

906


Give me example of derived data types.

1086


What are the disadvantages of object oriented programming?

1172


Is nan false?

915