After reading about the Oracle v. Google trial I looked up the famous 9 lines of code that Google allegedly stole from Oracle, which implement the rangeCheck method for arrays. Note that arrays and range checking are as common as dirt in programming languages.

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); }