Java工具類(四) 判斷數組/集合為空的工具類


判斷數組/集合為空的工具類

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;
	}
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM