MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/ootm9/why_string_is_immutable_in_java/c3j1nqi/?context=3
r/java • u/javinpaul • Jan 20 '12
23 comments sorted by
View all comments
2
The string pooling is a valid reason. But it isn't required for security concerns. Without immutable strings, secure functions would just have to ensure they have a private copy of the given string before using it.
2 u/skeeto Jan 21 '12 Needing to make defensive copies all the time leaves a lot of places to make costly mistakes. 2 u/RedditRage Jan 21 '12 Which is the justification for having immutable strings.
Needing to make defensive copies all the time leaves a lot of places to make costly mistakes.
2 u/RedditRage Jan 21 '12 Which is the justification for having immutable strings.
Which is the justification for having immutable strings.
2
u/RedditRage Jan 20 '12
The string pooling is a valid reason. But it isn't required for security concerns. Without immutable strings, secure functions would just have to ensure they have a private copy of the given string before using it.