String s = "";
s.length();
String s = null;
s.length();
A reference to an empty string ""
points to an object in the heap - so you can call methods on it.
But a reference pointing to null
has no object to point in the heap and thus you'll get a NullPointerException
.