What is the difference between StringBuilder and Stringbuffer?

Possible duplicate:
StringBuilder and StringBuffer in Java

What is the difference between StringBuilder and Stringbuffer?

+3
source share
2 answers

Some methods in StringBuffer are synchronized, and StringBuilder is not thread safe - and faster.

Rule of thumb - use StringBuilder if you have no use case where StringBuilder is used by more than one thread (this will be a very rare case).

+5
source

Taken from javadoc StringBuffer:

JDK 5, , thread, {@link StringBuilder}. StringBuilder , , .

StringBuffer , , , StringBuilder, .

+4

Source: https://habr.com/ru/post/1747361/


All Articles