判斷數組/集合為空的工具類
package com.cnblog.util;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 判斷 數組/集合 為空的工具類
* @author jian.liu
*
*/
public class ArrayUtil {
//判斷集合是否為空
public static boolean isEmpty(Collection<?> collection) {
return collection == null || collection.isEmpty();
}
//判斷Map是否為空
public static boolean isEmpty(Map<?, ?> map) {
return map == null || map.isEmpty();
}
//判斷數組是否為空
public static boolean isEmpty(Object[] array) {
return array == null || array.length == 0;
}
//判斷List是否為空
public static boolean isEmpty(List<Object> list) {
return list == null || list.size() == 0;
}
}