code: public void setRowGroups(int[][] rowGroupIndices) {
          int rowCount = getRowCount();
          boolean[] usedIndices = new boolean[rowCount + 1];
          for (int i = 0; i < rowGroupIndices.length; i++) {
              for (int j = 0; j < rowGroupIndices[i].length; j++) {
                  int rowIndex = rowGroupIndices[i][j];
                  if (rowIndex < 1 || rowIndex > rowCount) {
                      throw new IndexOutOfBoundsException(
                              "Invalid row group index " + rowIndex
                              + " in group " + (i + 1));
                  }
                  if (usedIndices[rowIndex]) {
                      throw new IllegalArgumentException(
                              "Row index " + rowIndex + " must not be used in multiple row groups.");
                  }
                  usedIndices[rowIndex] = true;
              }
          }
          this.rowGroupIndices = deepClone(rowGroupIndices);
      }
docs: Sets the row groups, where each row in such a group gets the same group wide height. Each
  group is described by an array of integers that are interpreted as row indices. The parameter
  is an array of such group descriptions.<p>
  
  <strong>Examples:</strong><pre>
  // Group rows 1 and 2.
  setRowGroups(new int[][]{ {1, 2}});
  
  // Group rows 1 and 2, and group rows 5, 7, and 9.
  setRowGroups(new int[][]{ {1, 2}, {5, 7, 9}});
  </pre>
  
  @param rowGroupIndices a two-dimensional array of row group indices.
  @throws IndexOutOfBoundsException if an index is outside the grid