public static int findMaxIndex ( int [ ] a ) { int max = a [ 0 ] ; int index = 0 ; for ( int i = 1 ; i < a . length ; i ++ ) { int val = a [ i ] ; if ( val > max ) { max = val ; index = i ; } } return index ; }
Finds the index in a with the largest value .