Here you can find the source of size(final Collection
public static <T> int size(final Collection<T> collection)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.Map; public class Main { public static <T> int size(final Collection<T> collection) { return collection == null ? 0 : collection.size(); }/*w w w . j av a 2 s.c om*/ public static <T, S> int size(final Map<T, S> map) { return map == null ? 0 : map.size(); } }