Java List Count count(List values)

Here you can find the source of count(List values)

Description

Derives the number of values for the given list of values.

License

Open Source License

Parameter

Parameter Description
values A list of values

Return

The number of values. If the list null or the size is equals 0, then return null.

Declaration

public static Integer count(List<?> values) 

Method Source Code

//package com.java2s;
/*//from  w  w  w  .  j av a 2 s  . c o m
 * Copyright (c) 2012-2013 Open Source Community - <http://www.peerfact.org>
 * Copyright (c) 2011-2012 University of Paderborn - UPB
 * Copyright (c) 2005-2011 KOM - Multimedia Communications Lab
 *
 * This file is part of PeerfactSim.KOM.
 * 
 * PeerfactSim.KOM is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 * 
 * PeerfactSim.KOM is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with PeerfactSim.KOM.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

import java.util.List;

public class Main {
    /**
     * Derives the number of values for the given list of values.
     * 
     * @param values
     *            A list of values
     * @return The number of values. If the list null or the size is equals 0,
     *         then return null.
     */
    public static Integer count(List<?> values) {
        if (values == null || values.size() == 0) {
            return 0;
        }
        return values.size();
    }
}

Related

  1. count(List l, int from, int to, Object what)
  2. count(List lines)
  3. countAtLevel(List aList, int aLevel)
  4. countNumber(List list, int number)
  5. countOccurances(List encodings, int value)