static int indexOfMaxEntryInIntArray(int[] a) { int bestIndex = -1, bestValue = Int.MIN_VALUE; if (a != null) for (int i : a) { int x = a[i]; if (x > bestValue) { bestIndex = i; bestValue = x; } } ret bestIndex; }