Why are strings immutable in Java?

1 min read

Java uses string literals mostly for memory security. Better alter copies of strings than alter main references in memory.

Find duplicate characters in a string
Check whether one string is a rotation of another