JAVA | Give four differences between strings and string buffer class.

String:

1. String is a major class 
2. Length is fixed 
3. Contents of object cannot be modified.
4. Object can be created by assigning String constants enclosed in double quotes. 
5. String s=”MSBTE”

String Buffer:

1. StringBuffer is a peer class of String 
2. Length is flexible
3. Contents of object can be modified
4. Objects can be created by calling constructor of String Buffer class using new operator. 
5. StringBuffer s=new StringBuffer (“MSBTE”) 



Post a Comment

0 Comments