In Python one can write if "string"
to test if a string is blank or contains all white-space characters.
if "somestring":
print(True)
else:
print(False)
Output: True
if "":
print(True)
else:
print(False)
Output: False
How could this easily be done in Java?
One could do the following, but the statement would evaluate to false if someString
contained any white-space characters:
if( someString.equals("") {
System.out.println(true);
} else {
System.out.println(false);
}
Aucun commentaire:
Enregistrer un commentaire