cdm/src/main/java/ucar/ma2/Index.java
public Index set(int[] index) {
    if (index.length != rank)
      throw new ArrayIndexOutOfBoundsException();
    if (rank == 0) return this;
    int prefixrank = (hasvlen ? rank : rank - 1);
    System.arraycopy(index, 0, current, 0, prefixrank);
    if (hasvlen) current[prefixrank] = -1;
    return this;
  }
public Index set(int[] index) {
    if (index.length != rank)
      throw new ArrayIndexOutOfBoundsException();
    if (rank == 0) return this;
    int prefixrank = (hasvlen ? rank : rank - 1);
    System.arraycopy(index, 0, current, 0, prefixrank);
    if (hasvlen) current[prefixrank] = -1;
    return this;
  }
Set the current element's index. General-rank case.

@param index set current value to these values
@return this, so you can use A.get(i.set(i))
@throws ArrayIndexOutOfBoundsException if index.length != rank.