I understand that every time I type the string literal \"\"
, the same String object is referenced in the string pool.
But why doesn\'t the String API in
To add on to what Noel M stated, you can look at this question, and this answer shows that the constant is reused.
http://forums.java.net/jive/message.jspa?messageID=17122
String constant are always "interned" so there is not really a need for such constant.
String s=""; String t=""; boolean b=s==t; // true