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

Name few java 8 annotations ?

808


What is byte data type?

783


Explain the difference between hashmap and hashtable in java?

734


What are the two ways to create a thread?

767


What is difference between static and final?

799


Can we overload the main() method?

791


How do you check if two given string are anagrams?

745


Which programming language is best in future?

741


What is the meaning of 3 dots in java?

901


What is the use of singleton class?

741


How many types of string data types are there?

777


What does the @override annotation do?

774


Can we store variables in local blocks?

1079


Is age a discrete variable?

748


What one should take care of, while serializing the object?

685