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 getRequest and PostRequest?

8 Answers   HCL, TCS,


How u validate date in DD/MM/YY format. and how u validate money in ur jsp

3 Answers   Ashok Leyland, Satyam, Tech Mahindra, Tomax,


what are memory considerations of jsp compares to other web components?

0 Answers   TCS,


What exceptions are thrown by RMI?

1 Answers  


what is a portable component?

0 Answers  






In a multitiered application which tier is the browser in?

3 Answers   Adobe,


Differences between applications and applets?

3 Answers  


i have a 1000 objects in data base i need to display those in jsp's how can i retrive those objects in jsp. (consider the performance issue)

2 Answers  


What is Remote Interface?

1 Answers  


whats is mean by connectionpooling

0 Answers   SolutionNET,


How many JSP scripting elements and what are they?

4 Answers   TCS,


How will the struts know which action class to call when you submit a form?

6 Answers   HeadStrong,


Categories