写个简单的,不为空的util
package com.gy.util; import org.junit.Test; import java.util.*; public class StrUtil { @Test public void test(){ List list = new ArrayList(); list.add("aa"); HashMap map = new HashMap<>(); Set set = new HashSet(); System.out.println(isNull(0)); } public static boolean isNull(Object o){ if(o==null)return true; if(o instanceof String){ o = ((String) o).trim(); if("".equals(o)||"null".equals(o)){ return true; } }else if(o instanceof Collection){ if(((Collection) o).size()==0){ return true; } }else if(o instanceof Map){ if(((Map) o).size()==0){ return true; } } return false; } public static boolean isNotNull(Object o){ return !isNull(o); } }