Java tutorial
//package com.java2s; import java.util.List; import java.util.Map; public class Main { /** * @param string * @return * @see #judgeNotNull(String, String...) */ public static boolean judgeNotNull(String string) { // return string != null && !string.equals("") && !string.equals("null") ? true : false; return judgeNotNull(string, new String[0]); } /** * Judge if a variable of String or String[] is null or "" * * @param string * @param strings * @return */ public static boolean judgeNotNull(String string, String... strings) { boolean flag = true; if (!(string != null && string.trim().length() > 0 && !string.equals("null") && !string.trim().equals(""))) return false; for (String s : strings) { if (s == null || string.trim().length() == 0 || s.equals("null")) { flag = false; break; } } return flag; } public static boolean judgeNotNull(byte[] bytes) { return bytes != null && bytes.length >= 1; } public static boolean judgeNotNull(Map map) { return map != null && map.size() > 0 ? true : false; } public static boolean judgeNotNull(List<?> list) { //return list != null && list.size() > 0 ? true : false; return judgeNotNull(list, null); } public static boolean judgeNotNull(List list, List[] lists) { boolean flag = true; if (list == null || list.size() == 0) return false; if (judgeNotNull(lists)) for (List l : lists) { if (l == null || l.size() == 0) { flag = false; return false; } } return flag; } public static boolean judgeNotNull(Object object) { return judgeNotNull(object, new Object[0]); } public static boolean judgeNotNull(Object object, Object... objects) { boolean flag = true; if (object == null) return false; for (Object o : objects) { if (o == null) { flag = false; return flag; } } return flag; } }