Java tutorial
//package com.java2s; import java.util.Collection; import java.util.Map; public class Main { /** * Returns the size of the specified collection or {@code 0} if the * collection is {@code null}. * * @param c * the collection to check * @return the size of the specified collection or {@code 0} if the * collection is {@code null}. * @since 1.2 */ public static int size(Collection c) { return c != null ? c.size() : 0; } /** * Returns the size of the specified map or {@code 0} if the map is * {@code null}. * * @param m * the map to check * @return the size of the specified map or {@code 0} if the map is * {@code null}. * @since 1.2 */ public static int size(Map m) { return m != null ? m.size() : 0; } }