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 the differnence between String Buffer and String
builder despite having knowledge that String builder is
faster than String Buffer and last one is threadsafe.please
tell another important difference.

Answers were Sorted based on User's Feedback



What is the differnence between String Buffer and String builder despite having knowledge that St..

Answer / rinaldoshi kalol

String is immutable whereas StringBuffer and StringBuilder
can change their values.

The only difference between StringBuffer and StringBuilder
is that StringBuilder is unsynchronized whereas
StringBuffer is synchronized. So when the application needs
to be run only in a single thread then it is better to use
StringBuilder. StringBuilder is more efficient than
StringBuffer.

Criteria to choose among String, StringBuffer and
StringBuilder

If your text is not going to change use a string Class
because a String object is immutable.
If your text can change and will only be accessed from a
single thread, use a StringBuilder because StringBuilder is
unsynchronized.
If your text can changes, and will be accessed from
multiple threads, use a StringBuffer because StringBuffer
is synchronous.

Is This Answer Correct ?    16 Yes 1 No

What is the differnence between String Buffer and String builder despite having knowledge that St..

Answer / sanjay

WHEN AN APPLICATION NEEDS TO BE RUN ONLY BY SINGLE THREAD
IT IS BETTER TO USE STRING BUILDER BECAUSE IT IS
UNSYNCHRONIZED

WHEN AN APPLICATION NEEDS TO BE RUN BY MULTIPLE THREADS IT
IS BETTER TO USE STRING BUFFER BECAUSE IT IS SYNCHRONIZED

Is This Answer Correct ?    9 Yes 3 No

What is the differnence between String Buffer and String builder despite having knowledge that St..

Answer / vinodkumar uttara student

StringBuilder all methods are not synchronized , nothing
changes done in this class , it is same as StringBuffer.I
mean to say , more than one thread can be execute
StringBuilder object , because there is not a concept of
lock on object , any thread can execute on this object.Where
as StringBuffer class all methods are synchronized only one
thread at time can access synchronized method , because it
get lock on object.

Please help me , if i am right?
is it correct,
thanks for the reply

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More Core Java Interview Questions

Difference between ?System.out.println? and ?System.error.println??

8 Answers   Sai Softech,


Is it safe for adding 10,00,000 records/objects to HashMap?, i.e is it safe to add millions of objects to HashMap?

2 Answers  


What are basic data types?

0 Answers  


how can you say that java is independ language

2 Answers   TCS, Wipro,


public class Base { public void myMethod(int a,intb) {} } // Uses myMethod and then hides it. public class DerivedOne extends Base { private void myMethod(int a,int b); } will this compile or not .yes or no. why

2 Answers  


can we access the method of class without creating the object of the class

3 Answers  


what is predefined function in java?

0 Answers  


What is difference between path and classpath?

0 Answers  


What are the main differences between the java platform and other platforms?

0 Answers  


What are design patterns and please explain?

0 Answers  


How many statements can be created with one connection in jdbc?

4 Answers   Polaris,


explain what is transient variable in java?

0 Answers  


Categories