Blogger

Delete comment from: Javarevisited

Fabrizio Benigni said...

Regarding the concern with class loading and possibly mutable strings, I think you're confusing the reasons behind the effects of making strings immutable with the effects of the implementation choices that were enabled by the decision of making stings immutable: immutable strings allowed optimizations such as the string pool, which would not make any sense had Strings not been immutable, so obviously there wouldn't be any problem with class loading and the like in case strings were mutable, as in that case we wouldn't have string pools and modifying my string object "java.io.Writer" to "gotcha.hahaha" wouldn't have any effect on another "java.io.Writer" object.

Jun 3, 2012, 7:34:19 PM


Posted to Why String is Immutable or Final in Java? Explained

Google apps
Main menu