The main difference between these two string operations is that isBlank()
strings with only spaces are accepted isEmpty()
and not .
isBlank()
example
"".isBlank() // true
" ".isBlank() // true
"hi".isBlank() // false
" hi ".isBlank() // false
isEmpty()
example
"".isEmpty() // true
" ".isEmpty() // false
"hi".isEmpty() // false
" hi ".isEmpty() // false
StringUtils
Runs the same way, except that the inputnull
will be returnedtrue
(for exampleStringUtils.isEmpty(null)和
StringUtils.isBlank(null)的返回值都是
true
).