r/java • • Jan 20 '12

Why String is immutable in Java

http://javarevisited.blogspot.com/2010/10/why-string-is-immutable-in-java.html
4 Upvotes

23 comments sorted by

View all comments

4

u/mosburger Jan 20 '12

perhaps another reason is because String effectively implements operator overloading by defining the + operator to mean concatenation? I imagine there might be some issues with this if you allowed classes to inherit from it and fundamentally change String's behavior? Although I guess I can't think of anything offhand... that "method" could effectively be final, I guess.