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...

String is a immutable objects . it means that string does
not change...........
But it will be chang.........
{
String s="kapil";
String s1="raj";
String s=s1;
then print(.......)
The String has been changed ..
how it is possible and why its called immutable objects

Answer Posted / christine

Immutable means if you apply any methods to a String, it
would not affect the original String you created.
For eg,

String s = "test";
s.concat(" two");
System.out.println(s);

The output is still "test" and not "test two";
Java pass by reference. If you use = to assign the string
to another string, then the reference would change.
Therefore your example changes the string.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain thread life cycle in java?

969


Can we restart a dead thread in java?

930


Explain the concept of hashtables?

1058


What is get () in java?

972


What do you understand by an io stream?

982


How is treeset implemented in java?

954


Can we cast any other type to boolean type with type casting?

893


How do you use wildcards?

982


How would you format a date in java? I.e. In the ddmmyyy format?

1316


What is default locale java?

1045


What is void keyword?

1040


What are the skills required for core java?

948


What is the integer of 16?

929


How many ways can you break a singleton class in java?

915


What is the protected method modifier?

988