Here you can find the source of min(int[] values)
public static int min(int[] values)
//package com.java2s; //License from project: Open Source License public class Main { public static int min(int[] values) { return min(values, 0, values.length); }//from www .j a v a 2 s . co m public static int min(int[] values, int begin, int end) { int index = minIndex(values, begin, end); if (index >= 0 && index < values.length) { return values[index]; } else { return Integer.MAX_VALUE; } } public static double min(double[] values) { return min(values, 0, values.length); } public static double min(double[] values, int begin, int end) { int index = minIndex(values, begin, end); if (index >= 0 && index < values.length) { return values[index]; } else { return Double.NaN; } } public static int minIndex(int[] values) { return minIndex(values, 0, values.length); } public static int minIndex(int[] values, int begin, int end) { int min = Integer.MAX_VALUE; int index = -1; if (checkArguments(values, begin, end)) { min = values[begin]; index = begin; for (int i = begin; i < end; i++) { if (values[i] < min) { min = values[i]; index = i; } } } return index; } public static int minIndex(double[] values) { return minIndex(values, 0, values.length); } public static int minIndex(double[] values, int begin, int end) { double min = Double.NaN; int index = -1; if (checkArguments(values, begin, end)) { min = values[begin]; index = begin; for (int i = begin; i < end; i++) { if (!Double.isNaN(values[i])) { if (values[i] < min) { min = values[i]; index = i; } } } } return index; } private static boolean checkArguments(final int[] values, final int begin, final int end) { if (values == null || values.length == 0) { return false; } if (begin < 0 || end >= values.length) { return false; } return true; } private static boolean checkArguments(final double[] values, final int begin, final int end) { if (values == null || values.length == 0) { return false; } if (begin < 0 || end > values.length) { return false; } return true; } }