示例代码:
public class Dept {
/**
* 字符串判空
*/
public static boolean strIsEmpty(String str) {
if (str == null) {
return true;
}
if ("".equals(str)) {
return true;
}
if (str.length() < 1) {
return true;
}
return false;
}
/**
* 多个字符串判空
*/
public static boolean strIsEmpty(String... value) {
for (String str : value) {
if (strIsEmpty(str)) {
return true;
}
}
return false;
}
public static void main(String[] args) {
System.out.println(strIsEmpty(""));
System.out.println(strIsEmpty("程序员小哲"));
System.out.println(strIsEmpty("ddd", "dddd", "222"));
System.out.println(strIsEmpty("ddd", "dddd", "", null));
}
}
运行结果:
版权声明:本文为xiaozhezhe0470原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。