Java – Comparision/Difference of String, StringBuffer & StringBuilder | Code Factory


Index Page : Link

Donate : Link

Medium Link : Link

Applications : Link

StringStringBufferStringBuilder
Immutable/not changedObjects are mutable/we can changeObjects are mutable/we can change
have concat methodhave append methodhave append method
equals() method meant for content comparisonequals() method meant for reference/address comparisonequals() method meant for reference/address comparison
there is no any capacity conceptdefault capacity is 16default capacity is 16
every method present in StringBuffer is Synchronizedno method present in StringBuilder is Synchronized
String is thread safe (All immutable object bydefault thread safe because no one can change value)at a time only one thread is allow to operate on StringBuffer object and hence it is thread safeat a time multiple thread are allowed to operate on StringBuilder object and hence it is not thread safe
threads are required to wait to operate on StringBuffer object and hence relatively performance slowthreads are not required to wait to operate on StringBuilder object and hence relatively performance is high
introduced in 1.0vintroduced in 1.5v

3 thoughts on “Java – Comparision/Difference of String, StringBuffer & StringBuilder | Code Factory”

  1. I beloved up to you will obtain carried out right here. The sketch is tasteful, your authored material stylish. however, you command get bought an edginess over that you would like be turning in the following. sick certainly come more previously again as precisely the similar nearly a lot ceaselessly within case you shield this hike.

    Liked by 1 person

Leave a reply to Lou Schrock Cancel reply