Java

isBlank() vs isEmpty()

---------------------------------------

isBlank()

Added in the JDK 11 release.

01

isEmpty()

Added in the JDK 1.6 release.

01

isBlank()

Returns true if a string is empty or only contains white space otherwise returns false.

02

isEmpty()

Returns true if the length of the string is 0, otherwise returns false.

02

isBlank()

It uses Character.isWhitespace(int) method to determine a white space character.

03

isEmpty()

It uses the length() method to determine the emptiness of a string.

03

Visit our website