WHAT IS THE DIFFERENCE BETWEEN STRING AND STRING BUFFER?

Pushpendra Singh

Total Post:241

Points:1205
Posted by  Pushpendra Singh
Java 
 2264  View(s)
Ratings:
Rate this:
  1. Pushpendra Singh

    Post:241

    Points:1205
    What is the difference between String and String Buffer?

    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.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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!