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 / anjani kumar jha


Now u add s= s+"Technologies";
so it will NessTechnologies because you append. and assign
new varible,means that new addition is assigned to s

take one example for more clarity

String x = "Java";
x.concat(" Rules!");
System.out.println(x);

output is x=java
because string is immutable.............think hard on it


Consider the following another example---------and think
about that

public class NewClass {

public static void main(String as[])
{
String s="abc";
String s1=s+"cde";
System.out.println(s);
System.out.println(s1);


String x = "Java";
x.concat(" Rules!");
System.out.println(x);
}

}
output is
s=abc;
s1=abcde
x=java

since u have added cde in s but still from the output it is
abc...............means string is immutable,

For more contact me
Anjani Kumar jha
09623154095
CDAC,PUNE

Is This Answer Correct ?    6 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

why Interface used?

991


What is the difference between Java1.4 and Java1.5

2318


what is the use of pojo (plain old java objects)? how it is interact with crystal reports? pls urgent

2183


Howto get an object that will perform date & time calculations then format it for output in some different locales with different date style.can ne1 tel me the answer of this question.pls

1922


Can we convert stringbuilder to string in java?

993


Is integer passed by reference in java?

1020


how to create multithreaded program? : Java thread

957


How to find the largest value from the given array.

1013


What is difference between local variable and global variable?

1026


What is a linkedhashmap java?

1007


What is default exception handling in java?

1035


How do you sort a string in java?

968


How are destructors defined in java?

1038


How many threads can I run java?

1121


How do you initialize an arraylist in java?

1047