If you use the special syntaxes for
String the JVM will try to optimize by re-using Strings that already exist in the Pool. This is more efficient if there are duplicate strings. The special syntaxes include
String s = "asfasfasd"; //directly naming
String x = s + "sdfsd"; // concatenation
If you make a String using the "new" operator an object will be created on the heap (where most objects live) even if there is a string object in the pool which matches it.
See this
thread from yesterday.
http://www.javaranch.com/ubb/Forum33/HTML/003680.html [This message has been edited by Cindy Glass (edited October 09, 2001).]