Java Array Max Value max(int[] array)

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

Description

max

License

Apache License

Return

the maximum value in this array,

Declaration

public static int max(int[] array) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//from w w w .jav  a2 s.  c  o  m
     * @return the maximum value in this array,
     */
    public static int max(int[] array) {
        int maxValue = array[0];
        for (int aVector : array) {
            if (maxValue < aVector) {
                maxValue = aVector;
            }
        }
        return maxValue;
    }

    /**
     * @return the maximum value in this array,
     */
    public static long max(long[] array) {
        long maxValue = array[0];
        for (long aVector : array) {
            if (maxValue < aVector) {
                maxValue = aVector;
            }
        }
        return maxValue;
    }

    /**
     * @return the maximum value in this array,
     */
    public static double max(double[] array) {
        double maxValue = array[0];
        for (double aVector : array) {
            if (maxValue < aVector) {
                maxValue = aVector;
            }
        }
        return maxValue;
    }
}

Related

  1. max(int[] arr)
  2. max(int[] arr)
  3. max(int[] arr, int count)
  4. max(int[] array)
  5. max(int[] array)
  6. max(int[] array)
  7. max(int[] array)
  8. max(int[] as)
  9. max(int[] data)