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.

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we define private and protected modifiers for the members in interfaces?

537


How can I become a good programmer?

490


How many digits is int32?

537


What is the syntax and characteristics of a lambda expression? Explain

544


Do I need to import java.lang package any time? Why?

741






Is jdk required on each machine to run a java program?

752


What is the difference between == and === javascript?

575


How can we avoid including a header more than once?

613


What is difference between equals and hashcode method?

572


Difference between string, stringbuffer and stringbuilder?

566


Which sorting algorithm is in place?

535


What is a lambda expression ? What's its use ?

565


What are the differences between heap and stack memory in java?

538


What is annotation in java?

576


Why deletion in linkedlist is fast than arraylist?

535