Posts

Showing posts from October, 2017

StringBuffer

Java StringBuffer class Java StringBuffer class is used to create mutable (modifiable) string. The StringBuffer class in java is same as String class except it is mutable i.e. it can be changed. Note: StringBuffer class is Thread-Safe, so multiple threads cannot access it simultaneously. So it is thread-safe, it is because all methods of StringBuffer class is synchronized . Important Constructors of StringBuffer class Constructor Description StringBuffer() creates an empty string buffer with the initial capacity of 16. StringBuffer(String str) creates a string buffer with the specified string. StringBuffer(int capacity) creates an empty string buffer with the  specified capacity as length. Important methods of StringBuffer class Modifier and Type Method Description public synchronized StringBuffer append(String s) is used to append the specified string with  this string. The a