1.

What Is Stringbuffer In Java?

Answer»

StringBuffer class is the companion class of String. StringBuffer is a mutable(modifiable) sequence of CHARACTERS which is in contrast to String class which is an immutable sequence of characters. Thus in case of StringBuffer length and CONTENT of the sequence can be changed through certain METHOD calls. 

Since StringBuffer is mutable a new String object is not created every time string is modified, which in turn results in less MEMORY consumptions and not having LOTS of intermediate String object for garbage collection.

StringBuffer class is the companion class of String. StringBuffer is a mutable(modifiable) sequence of characters which is in contrast to String class which is an immutable sequence of characters. Thus in case of StringBuffer length and content of the sequence can be changed through certain method calls. 

Since StringBuffer is mutable a new String object is not created every time string is modified, which in turn results in less memory consumptions and not having lots of intermediate String object for garbage collection.



Discussion

No Comment Found