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

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

Description

max

License

Open Source License

Declaration

public final static double max(double... values) 

Method Source Code

//package com.java2s;
/*// ww w  .  j a  va 2  s.  com
 * ====================================================
 * Copyright (C) 2013 by Idylwood Technologies, LLC. All rights reserved.
 *
 * Developed at Idylwood Technologies, LLC.
 * Permission to use, copy, modify, and distribute this
 * software is freely granted, provided that this notice
 * is preserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * The License should have been distributed to you with the source tree.
 * If not, it can be found at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Author: Charles Cooper
 * Date: 2013
 * ====================================================
 */

public class Main {
    public final static double max(double... values) {
        if (values.length == 0)
            return Double.NaN;
        double ret = values[0];
        for (int i = 1; i < values.length; i++)
            if (values[i] > ret)
                ret = values[i];
        return ret;
    }

    public final static int max(int... values) {
        if (values.length == 0)
            return Integer.MIN_VALUE;
        int ret = values[0];
        for (int i = 1; i < values.length; i++)
            if (values[i] > ret)
                ret = values[i];
        return ret;
    }
}

Related

  1. max(double... arr)
  2. max(double... ds)
  3. max(double... ds)
  4. max(double... elems)
  5. max(double... nums)
  6. max(double... values)
  7. max(double... values)
  8. max(double[] a)
  9. max(double[] arr)