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

Difference between String & StringBuffer

Answer Posted / vijayakumar chinnasamy

String :
1.Content does not change –immutable

2.final class (cant subclass)

3.compareTo() - compare the string
result : < , > , = --- dictionary order

4.reverse() not available

5.is not thread safe

Criteria to choose among String
If your text is not going to change use a string Class
because a String object is immutable.



StringBuffer:

1. Content can be change Mutable

2.Final class.

3. compareTo() Not available


4.reverse() available

Allocates room for 16-addition character space when no
specific length is specified.

5.is thread safe

Criteria to choose StringBuffer

If your text can changes, and will be accessed from
multiple threads, use a StringBuffer because StringBuffer is
synchronous

Is This Answer Correct ?    52 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

You can create a string object as string str = “abc”; why cant a button object be created as button bt = “abc”;? Explain

990


Can we instantiate interface in java?

1128


Can we have multiple classes in single file ?

1067


Explain which of the following methods releases the lock when yield(), join(),sleep(),wait(),notify(), notifyall() methods are executed?

1117


What is purpose of find feature?

1080


What are the 2 types of java programs?

1115


What are generic methods?

974


What is the main use of generics in java?

991


How many types of memory areas are allocated by jvm?

1045


Can a final method be overloaded?

944


What is unicode in java?

929


Under what conditions is an object’s finalize() method invoked by the garbage collector?

1044


What Is Composition?

1055


why java does not support unsigned keyword?

5254


What are sets in java?

946