You can use length , but this is a normal property, not a static one. Here you can find all the properties of the String class. If the length is 0 , the string is empty. Therefore, you can run your tests as follows if you want to distinguish between null String and empty:
if (!myString) { // string is null } else if (!myString.length) { // string is empty } else { // string is not empty }
Or you can use the Richie_W solution if you do not need to distinguish between empty and null strings.
sch
source share