Problem Statement
Why are Java Strings immutable? Give two benefits.
Explanation
Safety in sharing/caching (e.g., pool, classpath, keys) and security/thread-safety; also enables stable hash codes for map keys.
Practice Sets
This question appears in the following practice sets: