Java tutorial
//package com.java2s; import java.util.Collection; public class Main { public static <E> int sizeOf(Collection<E> c) { return isEmpty(c) ? 0 : c.size(); } public static boolean isEmpty(Collection<? extends Object> c) { return c == null || c.size() == 0; } public static boolean isEmpty(Object[] objs) { return objs == null || objs.length == 0; } }