code: public static int getMaxValueIndex (int[] values)
      {
          if (values == null || values.length == 0) {
              return -1;
          }
  
          int idx = 0;
          int max = values[idx];
          for (int ii = 1; ii < values.length; ii++) {
              if (values[ii] > max) {
                  max = values[ii];
                  idx = ii;
              }
          }
          return idx;
      }
docs: Returns the index of the maximum value in the given array of
  values, or <code>-1</code> if the array is <code>null</code> or
  zero-length.