MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vda9j/deleted_by_user/cersk66/
r/ProgrammerHumor • u/[deleted] • Jan 16 '14
[removed]
446 comments sorted by
View all comments
Show parent comment
1
it can't be more expensive than continuously reallocating the memory.
Strings are immutable in java so I would expect it to reallocate memory for each new string anyway.
2 u/StoleAGoodUsername Jan 17 '14 It uses the string pool, so I believe that unless the gc runs mid loop, you are still able to use the same "" in memory from before.Strings in java are really kinda odd.
2
It uses the string pool, so I believe that unless the gc runs mid loop, you are still able to use the same "" in memory from before.
Strings in java are really kinda odd.
View all comments
Show parent comment
1
u/Tmmrn Jan 17 '14
Strings are immutable in java so I would expect it to reallocate memory for each new string anyway.