Difference between String and StringBuffer
String is immutable: once created, the characters do not change. toUpperCase() returns a new String. The old one stays the same. That is why the String Pool can safely reuse literals.
Immutability also helps security (passwords, class names) and hashing (a String used as a HashMap key cannot silently change).
If you need to change text many times, use StringBuilder. Don’t fight String by concatenating in a loop.
Let's take this on the board with one tiny Main class — no extra files. Difference between String and StringBuffer — 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 Difference between String and StringBuffer.
Buffer = thread-safe builder.