The difference between isBlank() and isEmpty() in Java

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

StringUtilsRuns the same way, except that the input nullwill be returned true(for example StringUtils.isEmpty(null)和StringUtils.isBlank(null)的返回值都是true).

Guess you like

Origin blog.csdn.net/allway2/article/details/128154793#comments_28831301