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 / vinodkumar uttara student

StringBuilder all methods are not synchronized , nothing
changes done in this class , it is same as StringBuffer.I
mean to say , more than one thread can be execute
StringBuilder object , because there is not a concept of
lock on object , any thread can execute on this object.Where
as StringBuffer class all methods are synchronized only one
thread at time can access synchronized method , because it
get lock on object.

Please help me , if i am right?
is it correct,
thanks for the reply

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the benefit of using enum to declare a constant?

884


Why object class is super class for every class in java?

821


What is the difference between delete and delete[]

972


What is the collections api in java programming?

786


What is the structure of java?

769


In which language java is written?

767


Can you use abstract and final both with a method?

832


What about features of local inner class?

849


What is considered an anti pattern?

724


How do I get a substring?

754


What Is Composition?

808


What is the use of object and class classes?

813


What is a substring of a string?

824


Wha is the output from system.out.println(“hello”+null); ?

914


how can i use a nonsynchronized hashtable?

2332