Java 11 has added A new instance method isBlank()
to java.lang.String
class.
What\'s the basic difference between the exi
Java 11 added has new method called .isBlank()
in String
class
isBlank()
method is equal to str.trim().isEmpty()
in earlier to java 11 versionsisEmpty()
: Returns true if, and only if, length() is 0This is the internal implementation of isBlank()
method in String
class of java 11
public boolean isBlank() {
return indexOfNonWhitespace() == length();
}
private int indexOfNonWhitespace() {
if (isLatin1()) {
return StringLatin1.indexOfNonWhitespace(value);
} else {
return StringUTF16.indexOfNonWhitespace(value);
}
}