code: private static void rangeCheck(int length, int fromIndex, int toIndex) {
          if (fromIndex > toIndex) {
              throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")");
          }
          if (fromIndex < 0) {
              throw new ArrayIndexOutOfBoundsException(fromIndex);
          }
          if (toIndex > length) {
              throw new ArrayIndexOutOfBoundsException(toIndex);
          }
      }
docs: Checks that {@code fromIndex} and {@code toIndex} are in the range and
  throws an appropriate exception, if they aren't.