Back to Top

Friday 27 January 2012

JAVA: What are the differences between the String and StringBuffer classes?

String class :
  1. Once an object is created and initialized, it can't be changed because it is Immutable.
  2. String object can be created Implicitly and Explicitly.

StringBuffer class :
  1.  StringBuffer class is mutable(can be modified), length and content can be changed through certain method calls. 
  2. It creates object Explicitly.

1 Responses to “ JAVA: What are the differences between the String and StringBuffer classes? ”

nofearinc said...
22 July 2012 at 17:00

and also better use StringBuilder for non-synchronization calls for a better performance of building char arrays than the StringBuffer approach (available since J 5.0)


Post a Comment

Popular Posts

Subscribe via Email
Subscribe Java Interview Questions via Email
All Rights Reserved JAVA INTERVIEW QUESTIONS | Privacy Policy | Anijit Sarkar