Here you can find the source of minIndex(int[] ints)
Parameter | Description |
---|---|
ints | the array of integers |
public static int minIndex(int[] ints)
//package com.java2s; //License from project: Open Source License public class Main { /**// w w w . j ava 2 s. c om * Returns index of minimum element in a given * array of integers. First minimum is returned. * * @param ints the array of integers * @return the index of the minimum element */ public static /*@pure@*/ int minIndex(int[] ints) { int minimum = 0; int minIndex = 0; for (int i = 0; i < ints.length; i++) { if ((i == 0) || (ints[i] < minimum)) { minIndex = i; minimum = ints[i]; } } return minIndex; } /** * Returns index of minimum element in a given * array of doubles. First minimum is returned. * * @param doubles the array of doubles * @return the index of the minimum element */ public static /*@pure@*/ int minIndex(double[] doubles) { double minimum = 0; int minIndex = 0; for (int i = 0; i < doubles.length; i++) { if ((i == 0) || (doubles[i] < minimum)) { minIndex = i; minimum = doubles[i]; } } return minIndex; } }