What is the difference between String and StringBuffer?
The main difference is that in Java Strings are immutable, which makes them quite inefficient for concatenating large amounts of text, especially in extensive loops. For each String concatenation statement the Java runtime system must instantiate at least one additional String object and then dispose of it. StringBuffer is designed exactly to overcome this problem, to build string content in an editable internal buffer without generating lots of additional objects. StringBuffer has many convenience methods to append all Java primitive types, character arrays and objects, and to check and manipulate characters in the buffer. Actions: Follow-up or correct this answer. Submit a new question.