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

what is mutability?which one is mutable String or StringBuffer?and why?give
examples of each which shows the mutability of each String or StringBuffer

Answer Posted / rajender

if use
String s="raj";
here string object created in string content pool(scp).it
(scp)doesn't allow duplicate objects.so it is immutable

String s=s+"ramu";
here string object created in heap allows duplicate
objects.so it is immutable
in heap

String s=rajramu;

if use string buffer every time it will create object in
heap.heap allows duplicate object.so it is mutable
StringBuffer sb=new StringBuffer("raj");
StringBuffersb1=sb.append("ramu");

if u hav any questions related java just call me:9952942104

finally it create duplicate value in heap.

Is This Answer Correct ?    17 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the meaning of java applet.

1016


What is difference between Heap and Stack Memory?

980


How do you declare a variable?

1038


What is called module?

923


What is ascii format?

941


Can a class have 2 constructors?

848


How do you read and print a string in java?

907


How can we create a thread in java?

963


What is busy spin, and why should you use it?

1022


Why 1 is not a prime number?

978


Can there be an abstract method without an abstract class?

888


What is default constructors?

936


What is the parse method in java?

1050


What is nested loop? What is dangling else condition in it?

1021


What is the difference between Java and C++?

1124