This content has been marked as final. Show 1 reply
If the strings are literals--that is, they're in quotes in your source code--then they live in the constant pool. They're either never GCed, or they're eligible for GC when the class that defined them is unloaded, not sure which. If you refer to the same String literal again, you'll get that same object from the constant pool.
If the String doesn't come from the constant pool--e.g. read from a file or user input--then it will be eligible for GC when it's no longer reachable, like any other object.