posted 23 years ago
Hi, Akhil.
You are correct, String s = ""; creates an Object, whereas String s = null; does not. As for the contents of s when it contains an empty string, according to a comment in the source code of java.lang.String, "There is an empty string at index 0 in an empty string." Paradoxical, but it explains why s.endsWith( "" ) and s.startsWith( "" ) return true.
Also, String s = ""; is completely different from String s = " ";. An empty string is not the same as a String containing a space.
Hope this helps, Akhil.
Art