code: public static int whichMax(double[] x) {
          double m = Double.NEGATIVE_INFINITY;
          int which = 0;
  
          for (int i = 0; i < x.length; i++) {
              if (x[i] > m) {
                  m = x[i];
                  which = i;
              }
          }
  
          return which;
      }
docs: Returns the index of maximum value of an array.