StringBuilder vs StringBuffer vs String.

Updated Apr 28, 2026

Short answer

String is immutable; StringBuilder is mutable/non-thread-safe; StringBuffer is mutable/thread-safe.

Deep explanation

Intermediate string problems test your ability to use frequency maps and sliding windows. String is immutable; StringBuilder is mutable/non-thread-safe; StringBuffer is mutable/thread-safe.

Real-world example

Search filters that ignore character order.

Common mistakes

  • Inefficiently sorting strings for an anagram check when a frequency map is O(n).

Follow-up questions

  • What is the time complexity of sorting?

More Strings interview questions

View all →