The difference is slight between isEmpty()
and isBlank()
isBlank(inputString)
: Returns true if the specified String is white space, empty (''), or null; otherwise, returns false.
isEmpty(inputString)
: Returns true if the specified String is empty ('') or null; otherwise, returns false.
So the isEmpty()
function is a subset of isBlank()
function.
Usage
In case, your check is for a null string or a string which does not contain any value('')
, but in your usecase a String having a space is valid then use isEmpty()
.
If you want to check if your string is null or have no value or have only blank spaces you should use isBlank
To know more about the String class you can follow the following link : Documentation
Hope this helps..