The difference between isNotBlank and isNotEmpty

foreword

The difference between isNotBlank and isNotEmpty

the code

The isNotBlank() method is used to determine whether a string is a non-blank string.
The judgment rule for a non-blank string is:
the string is not null
and the length of the string is not 0 after removing the leading and trailing spaces,
so what it judges is not whether the string has a value, but whether the value of the string is meaningful after removing the spaces.
For example:


String str1 = "  hello  ";
String str2 = null;
String str3 = "";

str1.isNotBlank() 

Guess you like

Origin blog.csdn.net/qq_32370913/article/details/130506147