Java Collection Count count(Collection collection)

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

Description

count

License

Open Source License

Declaration

public static int count(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 count(Collection collection) {
        if (isEmpty(collection))
            return 0;
        return collection.size();
    }/*w  w w  .ja  v  a 2s. c o m*/

    public static int count(Map collection) {
        if (isEmpty(collection))
            return 0;
        return collection.size();
    }

    public static boolean isEmpty(Collection collection) {
        if (null == collection)
            return true;
        return collection.isEmpty();
    }

    public static boolean isEmpty(Map collection) {
        if (null == collection)
            return true;
        return collection.isEmpty();
    }
}

Related

  1. count(Collection collection)
  2. count(Collection ts, T toCount)
  3. count(final Collection collection, final ItemType item)
  4. count(final Collection blocks)