Here you can find the source of min(final int[] arr)
Parameter | Description |
---|---|
arr | The array. |
public static int min(final int[] arr)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w . j av a 2s .co m * Getter. * * @param arr The array. * @return The minimal value of the array. */ public static int min(final int[] arr) { if (arr.length == 0) throw new IllegalArgumentException("must not be empty"); int min = Integer.MAX_VALUE; for (final int v : arr) { if (v < min) { min = v; } } return min; } /** * Getter. * * @param arr The array. * @return The minimal value of the array. */ public static double min(final double[] arr) { if (arr.length == 0) throw new IllegalArgumentException("must not be empty"); double min = Double.NaN; for (final double v : arr) { if (v < min || Double.isNaN(min)) { min = v; } } return min; } }