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

What is an applet?

5 Answers  


What is in-memory replication?

0 Answers  


which deployment descriptor element is used to configure the authentication method? a. auth-config b. login-config c. sec-config

1 Answers  


What are the various thread priorities?

1 Answers  


What is jboss?

0 Answers  






Why DOM Parser would take more Memory than SAX parser while they are parsing?

3 Answers   OnMobile,


What are the oops concept?

0 Answers  


What is RMI Registry?

6 Answers   Siemens, United Software Solutions,


What is deadlock?

2 Answers  


I wantr to know, How many number of users logged in to website? can any one answer

7 Answers   Cap Gemini,


diff between jsp include directive and jsp action include?

2 Answers   SolutionNET,


What is a task?s priority?

1 Answers  


Categories