I understand that Strings may be interned, but it it an action that is performed religiously when a new string object is created?
Jls section 3.10.5 string literals.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
All
Stringliterals go into the string pool. Otherwise, your application must callintern()on theString, or it won’t go into the pool.A
Stringliteral is a string that appears in source code with double quotes around it:In this example,
"Hello, "is a literal string. It is in the intern pool. It is also referenced by the variablegreeting.The
Stringreferred to bysis not a literal, and is not in the intern pool… unless you make this call: