Garbage collection of String literals
问题 I am reading about Garbage collection and i am getting confusing search results when i search for String literal garbage collections. I need clarification on following points: If a string is defined as literal at compile time [e.g: String str = "java" ] then will it be garbage collected? If use intern method [e.g: String str = new String("java").intern() ] then will it be garbage collected? Also will it be treated differently from String literal in point 1. Some places it is mentioned that