Java List Min getMin(List numbers)

Here you can find the source of getMin(List numbers)

Description

Finds the minimum from a list of Doubles.

If the list is empty, 0 is returned.

License

Open Source License

Parameter

Parameter Description
numbers the list of Doubles

Return

the minimum

Declaration


public static double getMin(List<Double> numbers) 

Method Source Code

//package com.java2s;
/*/*ww w  . ja v  a2s .  com*/
 * File   : $Source: /alkacon/cvs/alkacon/com.alkacon.opencms.survey/src/com/alkacon/opencms/survey/CmsAverageUtil.java,v $
 * Date   : $Date: 2010/03/19 15:31:14 $
 * Version: $Revision: 1.2 $
 *
 * This library is part of OpenCms -
 * the Open Source Content Management System
 *
 * Copyright (C) 2010 Alkacon Software (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

import java.util.List;

public class Main {
    /**
     * Finds the minimum from a list of Doubles.<p>
     * 
     * If the list is empty, 0 is returned. 
     * @param numbers the list of Doubles
     * @return the minimum
     */

    public static double getMin(List<Double> numbers) {

        if (numbers.size() == 0) {
            return 0.0;
        }
        double min = numbers.get(0);
        for (Double number : numbers) {
            min = Math.min(min, number);
        }
        return min;
    }
}

Related

  1. findMin(List nums)
  2. findMin(List values)
  3. getMin(List numList)
  4. getMin(List aList)
  5. getMin(List d)
  6. getMinId(List ids)
  7. getMinimums(List data)
  8. getMinValue(List values)
  9. getMinWhitespace(final List lines)