// Find the index of the array element with the min. value public class MinArray2 { public static void main(String[] args) { double[] a = { 2.3, 3.4 , 4.5, 5.6, 1.2, 7.8, 8.9 }; // 7 elements int i; // Array index int min_i; // Current index with min value min_i = 0; // Assume element 0 (a[0]) has the min. value for ( i = 1 ; i < a.length ; i++ ) { if ( a[i] < a[min_i] ) { min_i = i; // Found a smaller min. value, update min_i ! } } System.out.println( min_i ); System.out.println( a[min_i] ); } }