Java Array Max Value max(long[] array)

Here you can find the source of max(long[] array)

Description

max

License

Open Source License

Parameter

Parameter Description
array a long array.

Return

the maximum of the values in this array.

Declaration

public static double max(long[] array) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by      //

public class Main {
    /**//  w  w  w  .j a va 2s  .c  o  m
     * @param array a long array.
     * @return the maximum of the values in this array.
     */
    public static double max(long[] array) {
        return max(array, array.length);
    }

    /**
     * @param array a double array.
     * @return the maximum of the values in this array.
     */
    public static double max(double[] array) {
        return max(array, array.length);
    }

    /**
     * @param array a long array.
     * @param N     the number of values of array which should be considered.
     * @return the maximum of the first N values in this array.
     */
    public static double max(long array[], int N) {

        double max = array[0];

        for (int i = 0; i < N; i++) {
            if (array[i] > max) {
                max = array[i];
            }
        }

        return max;
    }

    /**
     * @param array a double array.
     * @param N     the number of values of array which should be considered.
     * @return the maximum of the first N values in this array.
     */
    public static double max(double array[], int N) {

        double max = array[0];

        for (int i = 0; i < N; i++) {
            if (array[i] > max) {
                max = array[i];
            }
        }

        return max;
    }
}

Related

  1. max(int[] values)
  2. max(int[] vs)
  3. max(int[] x, int length)
  4. max(Long john, Long... jane)
  5. max(long[] array)
  6. max(long[] array)
  7. max(Number... array)
  8. max(Number[] array)
  9. max(T first, T... others)