Java tutorial
//package com.java2s; import java.util.Collection; import java.util.Map; public class Main { public static int getLength(Collection<?> collection) { if (collection == null) { return 0; } return collection.size(); } public static int getLength(Map<?, ?> map) { if (map == null) { return 0; } return map.size(); } }