Java Array Min Value min(double... value)

Here you can find the source of min(double... value)

Description

Calculates the minimum of the given parameters

License

Open Source License

Parameter

Parameter Description
value List of values to retrieve the minimum from

Return

The minimum value of all given values

Declaration

public static double min(double... value) 

Method Source Code

//package com.java2s;
/*//w w  w  .jav a 2  s  .c  o m
 * USE - UML based specification environment
 * Copyright (C) 1999-2010 Mark Richters, University of Bremen
 *
 * This program 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 2 of the
 * License, or (at your option) any later version.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

public class Main {
    /**
     * Calculates the minimum of the given parameters
     * @param value List of values to retrieve the minimum from
     * @return The minimum value of all given values
     */
    public static double min(double... value) {
        double min = Double.MAX_VALUE;

        for (double d : value) {
            min = Math.min(min, d);
        }

        return min;
    }

    /**
     * Calculates the minimum of the given parameters
     * @param useInt This parameter can be removed when Sun/Oracle fixes a <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6199075">bug</a> with parameter arrays.</br>
     *              The compiler wrongly determines max(double...) and max(int...) as ambiguous.
     * @param value List of values to retrieve the minimum from
     * @return The minimum value of all given values
     */
    public static int min(boolean useInt, int... value) {
        int min = Integer.MAX_VALUE;

        for (int d : value) {
            min = Math.min(min, d);
        }

        return min;
    }
}

Related

  1. min(double... a)
  2. min(double... args)
  3. min(double... d)
  4. min(double... ds)
  5. min(double... nums)
  6. min(double[] a)
  7. min(double[] a, double[] b)
  8. min(double[] arr)
  9. min(double[] arr)