Java 11 has added A new instance method isBlank()
to java.lang.String
class.
What's the basic difference between the existing isEmpty
and newly added isBlank()
method?
Java 11 has added A new instance method isBlank()
to java.lang.String
class.
What's the basic difference between the existing isEmpty
and newly added isBlank()
method?
isEmpty()
The java string
isEmpty()
method checks if this string is empty. It returns true, if the length of the string is 0 otherwise false e.g.Java 11 - isBlank()
The new instance method
java.lang.String.isBlank()
returns true if the string is empty or contains only white space, where whitespace is defined as any codepoint that returns true when passed to Character#isWhitespace(int).Before Java 11
After Java 11
Java 11 added has new method called
.isBlank()
inString
classisBlank()
method is equal tostr.trim().isEmpty()
in earlier to java 11 versionsisEmpty()
: Returns true if, and only if, length() is 0This is the internal implementation of
isBlank()
method inString
class of java 11