Java Array Min Value min(int... array)

Here you can find the source of min(int... array)

Description

min

License

Open Source License

Declaration

public static int min(int... array) 

Method Source Code

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

public class Main {
    public static int min(int... array) {
        if (array.length == 0)
            throw new ArrayIndexOutOfBoundsException();

        int min = Integer.MAX_VALUE;

        for (int i : array) {
            if (i < min)
                min = i;//  w  w w  . ja  v  a  2 s.  com
        }

        return min;
    }

    public static long min(long... array) {
        if (array.length == 0)
            throw new ArrayIndexOutOfBoundsException();

        long min = Long.MAX_VALUE;

        for (long l : array) {
            if (l < min)
                min = l;
        }

        return min;
    }

    public static float min(float... array) {
        if (array.length == 0)
            throw new ArrayIndexOutOfBoundsException();

        float min = Float.MAX_VALUE;

        for (float f : array) {
            if (f < min)
                min = f;
        }

        return min;
    }

    public static double min(double... array) {
        if (array.length == 0)
            throw new ArrayIndexOutOfBoundsException();

        double min = Double.MAX_VALUE;

        for (double d : array) {
            if (d < min)
                min = d;
        }

        return min;
    }
}

Related

  1. min(int receiver, int... others)
  2. min(int value1, int value2, int... values)
  3. min(int... _is)
  4. min(int... arr)
  5. min(int... array)
  6. min(int... list)
  7. min(int... numbers)
  8. min(int... vals)
  9. min(int... values)