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

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

Description

Computes the minimum value of a vararg of doubles.

License

Open Source License

Parameter

Parameter Description
The vararg of doubles.

Return

The minimum. Returns 0 if the parameter is null or the length of the vararg is 0.

Declaration

public static double min(double... a) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010-2015 BSI Business Systems Integration AG.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from www .j a  v a 2 s .co m*/
 *     BSI Business Systems Integration AG - initial API and implementation
 ******************************************************************************/

public class Main {
    /**
     * Computes the minimum value of a vararg of doubles.
     *
     * @param The
     *          vararg of doubles.
     * @return The minimum. Returns 0 if the parameter is null or the length of the vararg is 0.
     */
    public static double min(double... a) {
        if (a == null) {
            return 0;
        }
        if (a.length == 0) {
            return 0;
        }
        double min = Double.MAX_VALUE;
        for (double d : a) {
            min = Math.min(min, d);
        }
        return min;
    }
}

Related

  1. min(byte[] arr)
  2. min(byte[] array)
  3. min(byte[] values)
  4. min(double values[], boolean[] mask)
  5. min(double values[], int size)
  6. min(double... args)
  7. min(double... d)
  8. min(double... ds)
  9. min(double... nums)