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 are user defined exceptions?

590


What is string builder?

470


How destructors are defined in java?

630


How to convert string to char and vice versa?

515


How do you take thread dump in java?

560






What are the different types of collections in java?

530


What is integer size in java?

514


What is local variable and instance variable?

611


What is collection sort in java?

557


Explain what are final variable in java?

576


Explain about the select method with an example?

591


Can we override private methods?

546


Will the jvm load the package twice at runtime?

574


How do you convert an int to a string in java?

546


Is 0 true or false?

514