1public int getIndexOfLargest( int[] array )
2{
3 if ( array == null || array.length == 0 ) return -1; // null or empty
4
5 int largest = 0;
6 for ( int i = 1; i < array.length; i++ )
7 {
8 if ( array[i] > array[largest] ) largest = i;
9 }
10 return largest; // position of the first largest found
11}
1int largest = 0;
2for ( int i = 1; i < array. length; i++ )
3{
4if ( array[i] > array[largest] ) largest = i;
5}
6return largest; // position of the first largest found.
7}