private static void checkFromToBounds ( int arrayLength , int origin , int fence ) { if ( origin > fence ) { throw new ArrayIndexOutOfBoundsException ( "origin(" + origin + ") > fence(" + fence + ")" ) ; } if ( origin < 0 ) { throw new ArrayIndexOutOfBoundsException ( origin ) ; } if ( fence > arrayLength ) { throw new ArrayIndexOutOfBoundsException ( fence ) ; } }
Validate inclusive start index and exclusive end index against the length of an array .