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

Is hashset sorted in java?

1136


Distinguish between a predicate and a function?

951


How will you reverse a link list without using recursion?

996


What is main function purpose?

981


Is string passed by reference in java?

970


How to solve the problem of generating the unique hash keys with hash function?

1871


How can I debug the Java security exceptions and AccessControlExceptions?

1102


What is difference between jdk,jre and jvm?

1064


Which arithmetic operations can result in the throwing of an arithmeticexception?

983


Explain the concept of proper inheritance?

1023


What is the difference between private & public & friendly classes?

1036


How you can force the garbage collection?

943


What is the method overriding?

1056


What are the differences between forwarding () method and sendredirect() methods?

1078


Is integer passed by reference in java?

986