当前位置:网站首页>Isempty and isblank
Isempty and isblank
2022-07-21 20:16:00 【Rainbow sea.】
isEmpty
// Empty checks
//-----------------------------------------------------------------------
/** * <p>Checks if a CharSequence is empty ("") or null.</p> * * <pre> * StringUtils.isEmpty(null) = true * StringUtils.isEmpty("") = true * StringUtils.isEmpty(" ") = false * StringUtils.isEmpty("bob") = false * StringUtils.isEmpty(" bob ") = false * </pre> * * <p>NOTE: This method changed in Lang version 2.0. * It no longer trims the CharSequence. * That functionality is available in isBlank().</p> * * @param cs the CharSequence to check, may be null * @return {@code true} if the CharSequence is empty or null * @since 3.0 Changed signature from isEmpty(String) to isEmpty(CharSequence) */
public static boolean isEmpty(final CharSequence cs) {
return cs == null || cs.length() == 0;
}
isBlank
/** * <p>Checks if a CharSequence is empty (""), null or whitespace only.</p> * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}.</p> * * <pre> * StringUtils.isBlank(null) = true * StringUtils.isBlank("") = true * StringUtils.isBlank(" ") = true * StringUtils.isBlank("bob") = false * StringUtils.isBlank(" bob ") = false * </pre> * * @param cs the CharSequence to check, may be null * @return {@code true} if the CharSequence is null, empty or whitespace only * @since 2.0 * @since 3.0 Changed signature from isBlank(String) to isBlank(CharSequence) */
public static boolean isBlank(final CharSequence cs) {
int strLen;
if (cs == null || (strLen = cs.length()) == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if (!Character.isWhitespace(cs.charAt(i))) {
return false;
}
}
return true;
}
We can know from the source code ,isEmpty Judge whether it is empty and length ,isBlank It also determines whether it is a space .
边栏推荐
- mac brew install mysql 安装步骤
- markdown及IDEA快捷键
- fastjson @JSONField format 不生效的原因
- MySQL之DQL(数据查询语言)-常见函数
- 数据库针对上面的salaries表emp_no字段创建索引idx_emp_no
- n-gram
- ftp不能创建多级目录【循环创建问题】
- Starfish OS: create a new paradigm of the meta universe with reality as the link
- RSA public private key encryption tool class
- Database connection failed
猜你喜欢
fastJson数据类型中,解析JSONObject出现$ref: “$.list[0]“问题
Json工具 将对象转换为json格式字符串
Flutter obtains longitude and latitude through geolocator positioning plug-in and calls Gaode peripheral information interface
FL Studio 20.9 Chinese patch package for fruit composition software
How to successfully get offers from ant, jd.com, Xiaomi, Tencent and other major manufacturers
Starfish OS: create a new paradigm of the meta universe with reality as the link
1451 - Cannot delete or update a parent row 具有多个外键约束 删除子表数据行的问题
Linux Redis-6.2.6单机部署
针对部分软件无法开机自启动情况的解决措施(已解决)
【404】服务器启动成功,默认页面无法访问
随机推荐
微信公眾號開發接入,利用微信公眾平臺申請測試號進行本地開發
数据库设计 数据库系统概论(第五版)
Is it really necessary to add interfaces to each class in the service layer and Dao layer
The JSON tool converts objects to JSON format strings
MySQL之DQL(数据查询语言)-常见函数
[404] the server starts successfully, and the default page cannot be accessed
Linux Redis-6.2.6单机部署
数据库删除emp_no重复的记录,只保留最小的id对应的记录
One of the project optimization: the installation and use of redis cache database in the project, and strengthen the project reading operation
MySQL DQL (data query language) - common keywords
Web. Config custom class reading
Classloader and parental delegation mechanism
RSA public private key encryption tool class
MinIO详解
flutter自定义form表单,封装form表单组件
JSON tool class
Nacos-注册中心原理解析
[untitled]
NIO之Channel详解
【404】服务器启动成功,默认页面无法访问