isNotEmpty
时间: 2023-09-08 08:12:44 浏览: 130
isNotEmpty是一个方法,用于判断指定对象是否为非空。它支持判断CharSequence、Map、Iterable、Iterator和Array等类型的对象是否为空。\[1\]具体实现上,isNotEmpty等价于a != null && a.length > 0,而isNotBlank等价于a != null && a.length > 0 && str.trim().length > 0。\[2\]在日常使用中,可以使用isNotBlank()来解决大多数问题,而当需要对空格进行判断处理时,可以使用isNotEmpty()。\[2\]举个例子,当传入null时,isNotEmpty(null)的返回值为false;当传入空字符串时,isNotEmpty("")的返回值也为false;而当传入一个只包含空格的字符串时,isNotEmpty(" ")的返回值为true;当传入一个非空字符串时,isNotEmpty("bob")的返回值为true。\[3\]
#### 引用[.reference_title]
- *1* [工具类ObjectUtil中的isNotEmpty和isNotNull分析。](https://blog.csdn.net/qq_40684649/article/details/119826383)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [isNotBlank与isNotEmpty](https://blog.csdn.net/weixin_36723038/article/details/126090920)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [isNotEmpty()和isNotBlank()的用法及区别](https://blog.csdn.net/qq_38967583/article/details/109338200)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文