StringUtils里的isEmpty方法和isBlank方法的区别

StringUtils.isEmpty("yyy") = false
StringUtils.isEmpty("") = true
StringUtils.isEmpty("   ") = false

StringUtils.isBlank("yyy") = false
StringUtils.isBlank("") = true
StringUtils.isBlank("   ") = true

区别:
isEmpty:没有忽略空格参数,是以是否为空和是否存在为判断依据;
isBlank:在 isEmpty 的基础上进行了为空(字符串都为空格、制表符、tab 的情况)的判断。

总结:
isBlank:可以有空格;
isEmpty:不能有空格。

Original: https://www.cnblogs.com/gsxm/p/16186795.html
Author: ICE-CREAMMM
Title: StringUtils里的isEmpty方法和isBlank方法的区别

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/596909/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球