Java Array Min Value min(final int... numbers)

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

Description

min

License

Open Source License

Return

the smallest of the given numbers

Declaration

public static int min(final int... numbers) 

Method Source Code

//package com.java2s;
/*/*  w  w  w  . j a va  2s  .c om*/
 *    GeoTools - The Open Source Java GIS Toolkit
 *    http://geotools.org
 *
 *    (C) 2007-2008, Open Source Geospatial Foundation (OSGeo)
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation;
 *    version 2.1 of the License.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 */

public class Main {
    /**
     * @return the smallest of the given numbers
     */
    public static int min(final int... numbers) {
        if (numbers.length == 0) {
            throw new IllegalArgumentException("at least one parameter is required");
        }

        int min = numbers[0];
        for (int i = 1; i < numbers.length; i++) {
            int number = numbers[i];
            if (number < min) {
                min = number;
            }
        }

        return min;
    }
}

Related

  1. min(final double[] vec)
  2. min(final double[] vector)
  3. min(final float[] a, final float[] b)
  4. min(final int... array)
  5. min(final int... integers)
  6. min(final int... values)
  7. min(final int[] arr)
  8. min(final int[] values)
  9. min(final int[] values)