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.
- StringBuffer is synchronized where as StringBuilder is not synchronized.
- StringBuffer is thread safe that means at a time only a single thread is allowed to operate.
- StringBuilder is not thread safe that means at a time multiple threads are allowed to operate.
- StringBuffer performance is slow when compared to StringBuilder why because a thread has to wait in a StringBuffer.
- StringBuffer was introduced in the 1.0 version where as StringBuilder was introduced in 1.5 version.
No comments:
Post a Comment