What is a StringBuffer class?

What is a StringBuffer class and how does it differ from String Class?

In contrast to the String class which implements immutable character strings, the StringBuffer class implements mutable character strings. Not only can the character string in a string buffer gets changed, but the buffer’s capacity can also change dynamically. The capacity of a String Buffer is the maximum number of characters that a string buffer can accommodate, before its size is automatically augmented.

Both String and StringBuffer class are thread-safe.

The syntax for initializing String class object is:
String str1=”Hello”;
The syntax for initializing StringBuffer class object is:
StringBuffer sbr1= new StringBuffer (“hello”);
StringBuffer sbr2= new StringBuffer (10);
StringBuffer sbr3= new StringBuffer();
What is MAP and SortedMap interface?
A Map is an object that maps keys to values. It is not an extension of the collection interface rather it has own interface hierarchy...
Difference between static and dynamic class loading
Dynamic class loading: This is done by programmatically invoking the functions of a class loader at run time....
What is Bootstrap,Extension and System Class Loader?
Class loaders are the part of the Java Runtime Environment that dynamically loads Java classes into the Java virtual machine...
Post your comment