answersLogoWhite

0

what is the difference Siring buffers vs string?

Updated: 8/20/2019
User Avatar

Wiki User

11y ago

Best Answer

I assume you mean "StringBuffer". The String class is "final", meaning that once you create an object you can't change an object. Commands like:


String myString = "Hello";

myString = myString + " there";


are possible, but the second command in the above example will create a NEW object, instead of reusing the old one. If you do this a lot, this might be inefficient, and you may want to use the StringBuffer class instead. It has an appendmethod that lets you add text to the end of an existing text; this makes it ideal to create long text files, such as HTML files for example, in several steps. StringBuffer also has some additional methods which may come in handy. String, on the other hand, is built-in into the language; note the above example, where the text " there" is automatically assumed to be a String; also, the String concatenation (the plus sign).


User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference Siring buffers vs string?
Write your answer...
Submit
Still have questions?
magnify glass
imp