Java Array Max Value max(int... list)

Here you can find the source of max(int... list)

Description

Retrieves the maximum integer in the list

License

LGPL

Parameter

Parameter Description
list list of integer

Return

the maximum integer

Declaration

public static int max(int... list) 

Method Source Code

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

public class Main {
    /**/* w ww  .  j  av a 2 s  .  co m*/
     * Retrieves the maximum integer in the list
     * 
     * @param list
     *            list of integer
     * @return the maximum integer
     */
    public static int max(int... list) {
        int max = list[0];
        for (int i : list) {
            if (i > max) {
                max = i;
            }
        }
        return max;
    }

    /**
     * Retrieves the maximum long integer in the list.
     * 
     * @param list
     *            list of long integer
     * @return the maximum long integer
     */
    public static long max(long... list) {
        long max = list[0];
        for (long i : list) {
            if (i > max) {
                max = i;
            }
        }
        return max;
    }

    /**
     * Retrieves the maximum double in the list.
     * 
     * @param list
     *            list of double
     * @return the maximum double
     */
    public static double max(double... list) {
        double max = list[0];
        for (double i : list) {
            if (i > max) {
                max = i;
            }
        }
        return max;
    }
}

Related

  1. max(int array[])
  2. max(int value1, int value2, int... values)
  3. max(int... _is)
  4. max(int... args)
  5. max(int... array)
  6. max(int... values)
  7. max(int... values)
  8. max(int... values)
  9. max(int... values)