string builder vs string buffer
String vs StringBuilder vs StringBuffer
STRING STRINGBUFFER STRINGBUILDER
Storage String Pool Heap Heap
Modifiable Immutable Mutable Mutable
Thread Safe YES YES NO
Performance FAST VERY SLOW FAST
0
1
String vs StringBuilder vs StringBuffer:
String: Immutable version char sequences
StringBuilder: mutable version char sequences,
not synchronized
StringBuffer: mutable version char sequences,
synchronized , thread-safe, slow
String str = new String("a")
StringBuilder s2 = new StringBuilder("B") // MUTABLE
StringBuffer s2 = new StringBuffer("c") // Synchronized
Thank you!
1
0
4.2
5
The main similarity between String and StringBuffer class is that both are
thread safe.
The main difference is that String is immutable; StringBuffer is mutable.
Thank you!
5
0
4.33
6
They both mutable, they are exactly same but
String buffer is thread safe so it runs slower
than String builder.
We are using StringBuffer when we are doing parallel
testing since it is a thread safe.
Thank you!
6
0
4.4
5
The StringBuffer and StringBuilder
class both produces mutable string objects.
The main difference between
them is that StringBuffer is thread safe;
StringBuilder is not thread safe.
Thank you!
5
0
4.4
11
String is immutable and thread safe
String builder mutable and not thread safe
Thank you!
11
0
Are there any code examples left?
New code examples in category Java
-
Java 2022-03-27 21:35:04 Sort string array in case insensitive order and case sensitive order java
-
Java 2022-03-27 21:25:10 java -jar -l resources\es.porperties -i ejemplo.txt -o inject.bin
-
Java 2022-03-27 21:20:21 Debug & Fix a 2-Dimensional Array Java Console Application
-
Java 2022-03-27 20:40:19 TreeSet headSet(E toElement) method in java
-
Java 2022-03-27 19:30:06 close keyboard android
-
Java 2022-03-27 19:20:40 java measure execution time
-
Java 2022-03-27 19:10:06 how to add cardview support in android studio
-
Java 2022-03-27 18:55:08 android studio lower case letters on a button