The difference between isBlank() and isEmpty() in Java
The main difference between these two string operations is this: isBlank() accepts strings with only whitespace while isEmpty() does not.
isBlank() examples
"".isBlank() // true
" ".isBlank() // true
"hi".isBlank() // false
" hi ".isBlank() // false
isEmpty() examples
"".isEmpty() // true
" ".isEmpty() // false
"hi".isEmpty() // false
" hi ".isEmpty() // false
StringUtilsoperates the same way, except it will returntruefornullinputs (e.g.StringUtils.isEmpty(null)andStringUtils.isBlank(null)aretrue).