Here you can find the source of sizeOf(Collection collection)
@SuppressWarnings("rawtypes") public static int sizeOf(Collection collection)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.Map; public class Main { @SuppressWarnings("rawtypes") public static int sizeOf(Collection collection) { if (isEmpty(collection)) { return 0; }/*from w w w. j ava 2 s.co m*/ return collection.size(); } public static boolean isEmpty(Collection<?> collection) { return (collection == null || collection.isEmpty()); } /** * Return <code>true</code> if the supplied Map is <code>null</code> * or empty. Otherwise, return <code>false</code>. * @param map the Map to check * @return whether the given Map is empty */ public static boolean isEmpty(Map map) { return (map == null || map.isEmpty()); } }