public static void ensureOffsetLength ( final int arrayLength , final int offset , final int length ) { if ( offset < 0 ) throw new ArrayIndexOutOfBoundsException ( "Offset (" + offset + ") is negative" ) ; if ( length < 0 ) throw new IllegalArgumentException ( "Length (" + length + ") is negative" ) ; if ( offset + length > arrayLength ) throw new ArrayIndexOutOfBoundsException ( "Last index (" + ( offset + length ) + ") is greater than array length (" + arrayLength + ")" ) ; }
Ensures that a range given by an offset and a length fits an array of given length .