Differentiate between String and String Buffer.
String
|
String Buffer c
|
String is a major class
|
String Buffer is a peer class of String
|
Length is fixed (immutable)
|
Length is flexible (mutable)
|
Contents of object cannot be modified
|
Contents of object can be modified
|
Object can be created by assigning String constants enclosed in double quotes.
|
Objects can be created by calling constructor of String Buffer class using “new”
|
Ex:- String s=”abc”;
|
Ex:- StringBuffer s=new StringBuffer (“abc”);
|