Here you can find the source of rangeCheck(int length, int fromIndex, int toIndex)
Parameter | Description |
---|---|
length | the length of the array. |
fromIndex | the starting index. |
toIndex | the end index. |
private static void rangeCheck(int length, int fromIndex, int toIndex)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w .ja va2 s.co m*/ * Checks that {@code fromIndex} and {@code toIndex} are in the range and throws an appropriate * exception, if they aren't. * * @param length * the length of the array. * @param fromIndex * the starting index. * @param toIndex * the end index. */ 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); } } }