private void ensureIndex ( final int index ) { if ( index < 0 ) throw new IndexOutOfBoundsException ( "Index (" + index + ") is negative" ) ; if ( index > size ( ) ) throw new IndexOutOfBoundsException ( "Index (" + index + ") is greater than list size (" + ( size ( ) ) + ")" ) ; }
Ensures that the given index is non - negative and not greater than the list size .