code: public static int[] getMaxIndexes (int[] values)
      {
          int max = Integer.MIN_VALUE;
          int num = 0;
          int vcount = (values == null) ? 0 : values.length;
  
          for (int ii=0; ii < vcount; ii++) {
              int value = values[ii];
  
              if (value < max) {
                  // common case- stop checking things..
                  continue;
  
              } else if (value > max) {
                  // new max
                  max = value;
                  num = 1;
  
              } else {
                  // another sighting of max
                  num++;
              }
          }
  
          // now find the indexes that have max
          int[] maxes = new int[num];
          for (int ii=0, pos=0; pos < num; ii++) {
              if (values[ii] == max) {
                  maxes[pos++] = ii;
              }
          }
  
          return maxes;
      }
docs: Returns an array of the indexes in the given array of values that
  have the maximum value in the array, or a zero-length array if the
  supplied array of values is <code>null</code> or zero-length.