code: public void set(int i, int y) {
          if (response == null) {
              throw new IllegalArgumentException("The dataset has no response values.");            
          }
          
          if (response.getType() != Attribute.Type.NOMINAL) {
              throw new IllegalArgumentException("The response variable is not nominal.");
          }
          
          if (i < 0) {
              throw new IllegalArgumentException("Invalid index: i = " + i);
          }
  
          int nrows = size();
          if (i >= nrows) {
              for (int k = nrows; k <= i; k++) {
                  data.add(new Datum<>(new SparseArray()));
              }
          }
  
          get(i).y = y;
      }
docs: Set the class label of a datum. If the index
  exceeds the current matrix size, the matrix will resize itself.
  @param i the row index of entry.
  @param y the class label or real-valued response of the datum.