Here you can find the source of size(Collection> collection)
public static int size(Collection<?> collection)
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.Map; public class Main { public static int size(Collection<?> collection) { return isEmpty(collection) ? 0 : collection.size(); }// ww w. j a v a 2 s . c o m /** * Test se la collection IS EMPTY * * @param collection * @return */ 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(); } }