1、判断列表list为空的方法:
public static boolean isEmptyList(Collection<?> collection) {
return collection == null || collection.isEmpty();
}
Collection一个集合框架来的 也是一个集合接口 通过属性isEmpty()来判断有没有数据
2、判断Map为空的方法:
public static boolean isEmptyMap(Map<?, ?> map) {
return map == null || isEmptyList(map.keySet());
}
Map 是一个键值对映射的集合接口 通过map.keySet()方法来返回一个set再判断它是否为空