Difference between StringBuffer and StringBuilder?


The both StringBuffer and StringBuilder seem to be sane, but this is one of the irregularly asking interview questions. The following are the some point needs to remember.


  1. StringBuffer is synchronized where as StringBuilder is not synchronized.
  2. StringBuffer is thread safe that means at a time only a single thread is allowed to operate.
  3. StringBuilder is not thread safe that means at a time multiple threads are allowed to operate.
  4. StringBuffer performance is slow when compared to StringBuilder why because a thread has to wait in a StringBuffer.
  5. StringBuffer was introduced in the 1.0 version where as StringBuilder was introduced in 1.5 version.

No comments:

Post a Comment

What is Normalization?

Database normalization is a data design and organization process applied to data structures based on rules that help building relational dat...