what is stringBuffer and StringBuilder?

Answers were Sorted based on User's Feedback



what is stringBuffer and StringBuilder?..

Answer / anonymous

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

what is stringBuffer and StringBuilder?..

Answer / modi[achir communication]

All methods in StringBuffer class are Synchronized whereas
in StringBuilder class methods are not synchronized.
StringBuilder is faster than StringBuffer because of the
synchronized method in StringBuffer.

Is This Answer Correct ?    4 Yes 1 No

what is stringBuffer and StringBuilder?..

Answer / srinu

StringBuffer:-
1)All methods in String Buffer class are Synchronized.
2)Performance is slow because these are synchronized.

StringBuilder:-
1)StringBuilder class methods are not synchronized.
2)performance is faster.

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More Advanced Java Interview Questions

Difference between sleep and suspend?

3 Answers  


What is the difference between Process and Threads?

19 Answers  


what is the Scope of Final Keyword in Java?

1 Answers   HCL,


what is Static binding?

2 Answers   Wipro,


When a thread blocks on i/o, what state does it enter?

0 Answers  






difference between HashMap, Hashset and hashTable?

2 Answers   HCL, Infotech,


What is a class loader? What are the different class loaders used by jvm?

0 Answers  


whats is mean by filter?

1 Answers   SolutionNET,


What’s jboss jbpm?

0 Answers  


diff between jsp include directive and jsp action include?

2 Answers   SolutionNET,


what is default length of textfield ?

1 Answers  


what is activation monitor and what is its job?

1 Answers  


Categories