code: public static int Mode( int[] values ){
          int mode = 0, curMax = 0;
  
          for ( int i = 0, length = values.length; i < length; i++ )
          {
              if ( values[i] > curMax )
              {
                  curMax = values[i];
                  mode = i;
              }
          }
          return mode;
      }
docs: Calculate Mode value.
  @param values Values.
  @return Returns mode value of the histogram array.