code: public static void checkForValidSubArrayIndices(
          IntTuple parentSize, IntTuple fromIndices, IntTuple toIndices)
      {
          if (fromIndices.getSize() != parentSize.getSize())
          {
              throw new IllegalArgumentException(
                  "Parent is "+parentSize.getSize()+"-dimensional, " +
                  "but fromIndices is "+fromIndices.getSize()+"-dimensional");
          }
          if (toIndices.getSize() != parentSize.getSize())
          {
              throw new IllegalArgumentException(
                  "Parent is "+parentSize.getSize()+"-dimensional, " +
                  "but toIndices is "+toIndices.getSize()+"-dimensional");
          }
          int n = parentSize.getSize();
          for (int i=0; i<n; i++)
          {
              int p = parentSize.get(i);
              int f = fromIndices.get(i);
              int t = toIndices.get(i);
              if (f < 0 || t > p || f > t)
              {
                  throw new IllegalArgumentException(
                      "Invalid index range: "+fromIndices+
                      " to "+toIndices+" in "+parentSize);
              }
          }
      }
docs: Checks whether the given tuples specify a valid range for a sub-array
  of an array with the given parent size, and throws an
  <code>IllegalArgumentException</code> if not.
  
  @param parentSize The parent size
  @param fromIndices The start indices, inclusive
  @param toIndices The end indices, exclusive
  @throws NullPointerException If any of the given tuples is
  <code>null</code>
  @throws IllegalArgumentException If the indices are not valid. This
  is the case when the {@link IntTuple#getSize() size} of the start- or
  end indices is different than the parent size, or when
  <code>fromIndex &lt; 0</code> or
  <code>toIndex &gt; parentSize.get(i)</code>
  or <code>fromIndex &gt; toIndex</code> for any dimension.