Check out example codes for "java function that returns the index of the largest value in an array". It will help you in understanding the concepts better.

Code Example 1

public int getIndexOfLargest( int[] array )
{
  if ( array == null || array.length == 0 ) return -1; // null or empty

  int largest = 0;
  for ( int i = 1; i < array.length; i++ )
  {
      if ( array[i] > array[largest] ) largest = i;
  }
  return largest; // position of the first largest found
}

Learn ReactJs, React Native from akashmittal.com