when its going to change often with many thread involved
when it going to change often with single thread
Modifiable
Immutable
Mutable
Mutable
Thread Safe
Yes
Yes
No
Synchronized
Yes
Yes
No
Performance
Slow
Slower than StringBuilder but faster than String
Faster than StringBuffer
Storage Area
Constant String Pool
Heap
Heap
*mutable - can change the value of the object
*immutable - cannot change the value of the object
*heap - is created when the JVM is started and may increase or decrease in size as the application runs.
*string constant pool - a special memory location for string to reuse of string objects
( it does not create the same string object if there is already a string constant in the pool )
*mutable - can change the value of the object
*immutable - cannot change the value of the object
*heap - is created when the JVM is started and may increase or decrease in size as the application runs.
*string constant pool - a special memory location for string to reuse of string objects ( it does not create the same string object if there is already a string constant in the pool )