Java tutorial
//package com.java2s; import java.util.Collection; import java.util.Map; public class Main { public static int size(Collection<?> collection) { return isEmpty(collection) ? 0 : collection.size(); } public static boolean isEmpty(Collection<?> collection) { return collection == null || collection.isEmpty(); } public static boolean isEmpty(Object[] array) { return array == null || array.length == 0; } public static boolean isEmpty(Map<?, ?> map) { return map == null || map.isEmpty(); } }