提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
返回给定数组中最小元素的索引
//package com.nowjava; /* 来自 n o w j a v a . c o m*/ public class Main { public static void main(String[] argv) throws Exception { double[] value = new double[] { 34.45, 35.45, 36.67, 37.78, 37.0000, 37.1234, 67.2344, 68.34534, 69.87700 }; System.out.println(minIndex(value)); } /** * returns the index of the smallest element from the given array */ public static double minIndex(double[] value) { double result = Double.POSITIVE_INFINITY; int index = 0; for (int i = 0; i < value.length; i++) {