StringBuffer in Java
StringBuffer is a mutable text builder. append, insert, reverse change the same object. Methods are synchronized — safer if two threads share it, a bit slower.
In a single-thread student program, StringBuilder is usually the better pick. Use StringBuffer when the buffer is shared across threads.
Don’t build a long string with + in a loop. Use append.
Let's take this on the board with one tiny Main class — no extra files. StringBuffer in Java — same append idea as Builder, but synchronized. Start from main, go line by line, and stop at each print. That output is the proof for StringBuffer.
Mutable + synchronized. Prefer StringBuilder unless two threads share it.