what is difference between String buffer and String builder?

Answers were Sorted based on User's Feedback



what is difference between String buffer and String builder?..

Answer / chithra

String Buffer is Sybchronized where as String Builder is not.

Is This Answer Correct ?    20 Yes 1 No

what is difference between String buffer and String builder?..

Answer / subhareddy

There is no much difference between string buffer and string
builder.only thing is all the methods available in string
buffer class are synchronized methods.and the method
available in string builder class are non-synchronized methods.
If we want thread safety then we have to go for string
buffer ,but performance goes down.if we don't want thread
safety the we can go for string builder

Is This Answer Correct ?    14 Yes 1 No

what is difference between String buffer and String builder?..

Answer / mohan

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 ?    4 Yes 0 No

what is difference between String buffer and String builder?..

Answer / rajujohn

hi All
Both are mutable ,that means we can change value of the
instance variable using append,insert and ...
But only one difference when you go for the multi-thread
concept you use StringBuffer,Because it is thread safe ,that
means, if one thread access this stringbuffer variable on
the time another thread cant access this stringbuffer,so
stringbuffer is slowest performance compare to stringbuilder.

by raju.j

Is This Answer Correct ?    2 Yes 1 No

what is difference between String buffer and String builder?..

Answer / radhakrishnan

Please visit
http://yourjavatutor.blogspot.in/2011/12/difference-between-stringstringbuffer.html
for more details

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Core Java Interview Questions

When do we need to use internal iteration? When do we need to use external iteration?

0 Answers  


can we create object for static class in java

14 Answers   IAP Company, IBM, Marlabs, mPortal, TCS,


Which is bigger float or double java?

0 Answers  


What is meant by stack and queue?

0 Answers   GrapeCity,


Why do we override tostring method in java?

0 Answers  






What is better - 'bit-shift a value' or 'multiply by 2'?

0 Answers   DELL,


How to display all the prime numbers between 1 and n (n is the number, get the input from user)

0 Answers  


Explain the private field modifier?

0 Answers  


Explain about data types?

0 Answers  


whether java is fully object oriented language or partially object oriented language

4 Answers   Infosys, ME, SMK,


What is an accessor?

1 Answers   BirlaSoft,


What is a dynamic array in java?

0 Answers  


Categories