code:
/** * 多参数非空校验 * * @param params * @return */ public static boolean nullOrEmpty(String... params) { if (params != null) { for (String param : params) { if (param == null || "".equals(param.trim())) { return true; } } } return false; }
test:
public static void main(String[] args) { boolean rev = nullOrEmpty("name", null); System.out.println(rev);// false rev = nullOrEmpty("name", ""); System.out.println(rev);// false rev = nullOrEmpty("name", "name-col1"); System.out.println(rev);// true }
原文地址:https://www.cnblogs.com/huakaiyoushi/p/11250004.html
时间: 2024-10-04 20:58:41