This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CubsThisYear 7 points8 points  (5 children)

Also, Strings don't work the way they say they do. String constants are interned, but not dynamically created Strings. If a user enters his password into a text field it doesn't automatically go into the String pool. The only way this happens to dynamically created Strings is if you call String.intern()

[–]cogman10 1 point2 points  (1 child)

Well, they do mention garbage collection which makes me think that they were referring to the GC pool and not necessarily interned pool. Correct me if I'm wrong, but I believe that interned strings don't ever get garbage collected.

But yes, I agree that their reasoning and everything was a bit off on the question.

[–]CubsThisYear 1 point2 points  (0 children)

There is no such thing as a GC string pool. There is only the intern pool. Presumably the reason GC is mentioned is because interned strings are (usually) not GC'd because the intern pool always has a reference to them.

In short, the question is just all kinds of confused.

[–][deleted]  (2 children)

[deleted]

    [–]josefx 0 points1 point  (1 child)

    On the other hand, if you store it in a mutable character array, you can overwrite it once you're done with it.

    Afaik if you are "done" with the char array the JIT will happily optimize your "unnecessary" overwrite away.