Java examples for java.util:Collection Attribute
get Collection Size
//package com.java2s; import java.util.Collection; public class Main { public static void main(String[] argv) { Collection collection = java.util.Arrays.asList("asdf", "java2s.com"); System.out.println(getSize(collection)); }/* w ww. j av a2 s. c o m*/ public static int getSize(Collection<?> collection) { return collection == null ? 0 : collection.size(); } }