Similarity and Different between String and StringBuffer Class

In this blog, we will see similarity and different between String and StringBuffer Class.

Similarity of String and StringBuffer Class

String FunctionsStringBuffer Function
String s1 = new String(“demo Text”);StringBuffer s1 = new StringBuffer(“demo Text”);


Above table mention all similar functions use in both String and StringBuffer. We already know about length(), charAt(), getChars(), replace(), substring(), indexOf(), lastIndexOf() function in String Class. You can also work on this function in StringBuffere Class.

Different of String and StringBuffer

String FunctionsStringBuffer Function
setCharAt() Not workingsetCharAt()
append() Not Workingappend()
insert() Not Workinginsert()
reverse() Not Workingreverse()
delete() Not Workingdelete()
deleteCharAt() Not WorkingdeleteCharAt()
String s1 = “demo Text”; – WorkingStringBuffer s1 = “demo Text”; – Not Working


Above table mention all different functions. We will see all setCharAt(), append(), insert(), reverse(), delete() and deleteCharAt() functions in our next blogs.


String s1 = “demo Text”; statement is valid in String Class.

But we can’t use StringBuffere s1 = “demo Text”;


If you have any query on blog example, you can directly comment us or subscribe our website

Earn Money Online

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

199total visits,3visits today


Hello, I am Maddy a Java blogger, trainer and developer

Related articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Your comments (*)

Name (*)

Your full name please.

Email address (*)

Used for gravatar.


Link back if you want.

Enter Captcha Here :*

Reload Image