Java Array Max Value max(double... a)

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

Description

Computes the maximum value of a vararg of doubles.

License

Open Source License

Parameter

Parameter Description
The vararg of doubles.

Return

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

Declaration

public static double max(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  w  ww  .j ava 2 s  .  c  o  m
 *     BSI Business Systems Integration AG - initial API and implementation
 ******************************************************************************/

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

Related

  1. max(byte[] values)
  2. max(D... comparables)
  3. max(double array[], int start, int length)
  4. max(double values[])
  5. max(double values[], int size)
  6. max(double... arr)
  7. max(double... ds)
  8. max(double... ds)
  9. max(double... elems)