If the method returns an empty string, it returns an object (a reference to it), and you can work with it when it returns null, then you cannot work with it because there is nothing to work with it.
String s = ""; s.isEmpty(); // returns true String s = null; s.isEmpty(); // throws null pointer exception.
It is better to return an empty string if you want to have more reliable code, but if you return zero, then null pointers will help you find some errors in your logic. Perhaps working with empty lines is not suitable, then a zero value will help you find places where there are no necessary checks.
kornero
source share