Java Collection Size size(Collection collection)

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

Description

Null-safe operation to determine the size of a collection.

License

Open Source License

Parameter

Parameter Description
collection Collection to compute size for.

Return

Returns 0 if the collection is null, otherwise the number of elements in the collection.

Declaration

public static int size(Collection collection) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

public class Main {
    /**//from   ww  w . j a  va  2 s .  co m
     * Null-safe operation to determine the size of a collection.
     *
     * @param collection Collection to compute size for.
     * @return Returns 0 if the collection is null, otherwise the number of elements in the collection.
     */
    public static int size(Collection collection) {
        return collection == null ? 0 : collection.size();
    }
}

Related

  1. size(Collection c)
  2. size(Collection c)
  3. size(Collection collection)
  4. size(Collection... collections)
  5. size(Collection collection)
  6. size(Collection c)
  7. size(Collection c)