Java tutorial
//package com.java2s; import java.util.Collection; public class Main { public static final <T> boolean isNullOrEmpty(Collection<T> collection) { if (collection == null || collection.isEmpty()) { return true; } for (T item : collection) { if (item != null) { return false; } } return true; } public static final <T> boolean isNullOrEmpty(T[] array) { if (array == null || array.length <= 0) { return true; } for (T item : array) { if (item != null) { return false; } } return true; } }