时间:2022-08-11 11:28:35 | 栏目:JAVA代码 | 点击:次
1、CollectionUtils.isEmpty(null): true
2、例:List<String> a = new ArrayList<>(); //a.size()==0
CollectionUtils.isEmpty(a): true
3、例:
List<String> list = new ArrayList<>(); list.add("a"); list.add("b"); System.out.println(list); //list.size()==2 CollectionUtils.isEmpty(list): false
1、CollectionUtils.isNotEmpty(null): false
2、例:List<String> a = new ArrayList<>(); //a.size()==0
CollectionUtils.isNotEmpty(a): false
3、例:
List<String> list = new ArrayList<>(); list.add("a"); list.add("b"); System.out.println(list); //list.size()==2 CollectionUtils.isNotEmpty(list): true
public static boolean isNotEmpty(Collection coll) { return !isEmpty(coll); } public static boolean isEmpty(Collection coll) { return coll == null || coll.isEmpty(); }
org.springframework.util.CollectionUtils
//Collection public static boolean isEmpty(Collection collection) { return collection == null || collection.isEmpty(); } //Map public static boolean isEmpty(Map map) { return map == null || map.isEmpty(); }