String is immutable so it can be safely shared between threads, cached/interned in the String pool, and reliably used as a key in hash‑based collections (stable hashCode). It also improves security because values like class names or file paths can’t be modified after creation.
Expanding on the short answer — what usually matters in practice:
A tiny example (an explanation template):
// Example: discuss trade-offs for "why-is-string-immutable-in-java?"
function explain() {
// Start from the core idea:
// For security, synchronization (thread-safety), and optimization through the String Constan
}