You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gym/StringUtil.java

31 lines
896 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.utils;
// 字符串工具类,提供字符串判空相关方法
public class StringUtil {
// 判断字符串是否为空
// 空值条件null、空字符串或"null"字符串
public static boolean isEmpty(String s) {
// 检查字符串是否为null
if (s == null) {
return true;
}
// 检查字符串是否为空字符串
if (s.equals("")) {
return true;
}
// 检查字符串是否为"null"字符串
if (s.equals("null")) {
return true;
}
// 不满足以上条件则返回false
return false;
}
// 判断字符串是否非空
// 直接调用isEmpty方法取反
public static boolean isNotEmpty(String s) {
// 返回isEmpty方法的相反结果
return !StringUtil.isEmpty(s);
}
}