What is StringBuffer class?
- StringBuffer class is same as String class except that it is mutable.
- It allows change and does not create a new instance on change of value.
- It consumes less memory when you concat strings.
- It is used for creating mutable string.
String vs. StringBuffer class.
String | StringBuffer |
It is immutable. | It is mutable. |
It is slow. | It is fast. |
It consumes more memory. | It consumes less memory. |
It overrides the equals() method of the object class. | It does not override the equals() method of the object class. |