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

What is mean by collections in java?

783


What is the method to expand and collapse nodes in a jtree?

815


Write a program to print the pattern given below

716


What is scope & storage allocation of global and extern variables? Explain with an example

793


How to sort an unsorted array in java?

865


How many bits is size_t?

742


Explain wrapper classes in java?

760


What is the full name of java?

812


Can you have two constructors in java?

691


Can you extend main method in java?

845


Is null a string in java?

764


What is method overloading and method overriding?

762


Enlist few advantages of inheritance?

845


what is the purpose of "virtual"?

805


Can we have any code between try and finally blocks?

777