Difference between String,Stringbuffer and Stringbuilder

String plays major role in Java applications. Below table differentiates the String, StringBuffer and StringBuilder classes. And also address which class is suitable for which scenarios. StringBuilder is a class introduced in java 1.5 and we will see how it differs from String and StringBuffer.
String
StringBuffer
StringBuilder
String object is immutable
StringBuffer is mutable
StringBuilder is mutable
Synchronized
Unsynchronized
Suitable for Single thread as well as Multithread
Suitable for Single thread as well as Multithread
If it is single thread application better to use StringBuilder instead of String and StringBuffer
Not efficient compare to StringBuilder
Not efficient compare to StringBuilder
More efficient for single thread
Unsynchronized so it should be faster than String and StringBuilder
About mohan

This is Mohan Jayapalan author of TechPages Blog.I am a part time blogger and Currently working for private Software Concern.

© Copyright 2010-2016 www.techpages.org · All Rights Reserved · Powered by WordPress ·