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

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

Description

max

License

Open Source License

Declaration

public static int max(int... xs) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int max(int... xs) {
        if (xs.length == 0)
            throw new RuntimeException("ArrayHelper.max cannot be used on an empty array.");
        int v = Integer.MIN_VALUE;
        for (int x : xs) {
            if (x > v)
                v = x;//from ww w  .j  a v a2  s. c om
        }
        return v;
    }

    public static double max(double... xs) {
        if (xs.length == 0)
            throw new RuntimeException("ArrayHelper.max cannot be used on an empty array.");
        double v = Double.MIN_VALUE;
        for (double x : xs) {
            if (x > v)
                v = x;
        }
        return v;
    }
}

Related

  1. max(int... list)
  2. max(int... values)
  3. max(int... values)
  4. max(int... values)
  5. max(int... values)
  6. max(int[] a)
  7. max(int[] a)
  8. max(int[] arr)
  9. max(int[] arr)