Here you can find the source of size(Collection
public static <E> int size(Collection<E> values)
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.Map; public class Main { public static <E> int size(Collection<E> values) { int result = 0; if (values != null) { result = values.size();/*from www .j a v a2s .c om*/ } return result; } public static <K, V> int size(Map<K, V> values) { int result = 0; if (values != null) { result = values.size(); } return result; } }