Created
May 18, 2016 16:04
-
-
Save josefdlange/53c90fbf95b2d837959cd4441f6ef73d to your computer and use it in GitHub Desktop.
Range Check. Definitely not patented or copyrighted by Oracle. (https://majadhondt.wordpress.com/2012/05/16/googles-9-lines/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This is _definitely_ my own implementation of rangeCheck and no one else's. Definitely not infringing on anything. | |
| private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) { | |
| if (fromIndex > toIndex) | |
| throw new IllegalArgumentException("fromIndex(" + fromIndex +") > toIndex(" + toIndex+")"); | |
| if (fromIndex < 0) | |
| throw new ArrayIndexOutOfBoundsException(fromIndex); | |
| if (toIndex > arrayLen) | |
| throw new ArrayIndexOutOfBoundsException(toIndex); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment