by CiPHPerCoder · 10y ago · 0 comments
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);
}
Missing a closing paren in the function prototype, among other things. private static void rangeCheck(int arrayLen, int fromIndex, int toIndex)
{
if (fromIndex > toIndex) {
throw new IllegalArgumentException(
String.format("fromIndex(%d) > toIndex(%d)", fromIndex, toIndex)
);
}
if (fromIndex < 0) {
throw new ArrayIndexOutOfBoundsException(fromIndex);
}
if (toIndex > arrayLen) {
throw new ArrayIndexOutOfBoundsException(toIndex);
}
}
There you go Google, Oracle, et al. I release this snippet under MIT / WTFPL / CC0. You're welcome.