null:
指一个字符串没有初始化,没有指向任何对象
empty:
空串 string str=“”
isNotEmpty:不为空串
Checks if a String is not empty (“”) and not null.
* <pre>
* StringUtils.isNotEmpty(null) = false
* StringUtils.isNotEmpty("") = false
* StringUtils.isNotEmpty(" ") = true 多个空格也不是空串
* StringUtils.isNotEmpty("bob") = true
* StringUtils.isNotEmpty(" bob ") = true
* </pre>
isNotBlank:内容不为空,不为空白
Checks if a String is not empty (“”), not null and not whitespace only.
* StringUtils.isNotBlank(null) = false
* StringUtils.isNotBlank("") = false
* StringUtils.isNotBlank(" ") = false 即使有多个空格,也属于空白串
* StringUtils.isNotBlank("bob") = true
* StringUtils.isNotBlank(" bob ") = true
本文详细介绍了在编程中如何判断字符串是否为空或空白的情况,包括null、empty和blank的区别,并通过具体的示例展示了StringUtils类中的isNotEmpty和isNotBlank方法的使用方式。
462

被折叠的 条评论
为什么被折叠?



