Difference between String & StringBuffer

Answer Posted / niranjanravi

String objects are constants and immutable where as
StringBuffer objects are not.StringBuffer Class supports
growable and modifiable string where as String class
supports constant strings. Strings once created we cant
modify them. Any such attempt will lead to the creation of
new strings.Where as StingBuffer objects after creation
also can be able to delete oo append any characteres to
it.String values are resolved at run time where as
StringBuffer valuesc are resolved at compile time.So if you
know the exact size of the string to be appended it is
better to go for String objects.

Is This Answer Correct ?    194 Yes 19 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are strings in physics?

533


Why heap memory is called heap?

578


What are the features of junit?

588


Can constructor be synchronized?

527


What is dot operator?

563






What is the purpose of void?

526


Does java have a compiler?

551


Why do we use variables?

505


What is a type parameter in java?

523


what is the difference between future and callable interface in java?

594


Explain what access modifiers can be used for methods?

557


Can a java program have 2 main methods?

537


What does nextint () do in java?

544


what is the swingutilities.invokelater(runnable) method for? : Java thread

539


What is return null in java?

501