Java Collection Size size(Collection collection)

Here you can find the source of size(Collection collection)

Description

size

License

Open Source License

Declaration

public static int size(Collection<?> collection) 

Method Source Code

//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();
    }
}

Related

  1. size(Collection collection)
  2. size(Collection c)
  3. size(Collection c)
  4. size(Collection col)
  5. size(Collection coll)
  6. size(Collection values)
  7. size(Collection v)
  8. size(final Collection collection)
  9. size(final Collection collection)