If the two lists are arguments passed to the method, it IllegalArgumentExceptionwill be a good candidate for a throw. This is a subclass of the class RuntimeException, so you will still throw a kind RuntimeException.
if (objctArray.length != columnArray.length) {
throw new IllegalArgumentException(String.format("objctArray and columnArray length is not same. objctArray length = %d, columnArray length = %d", objctArray.length, columnArray.length));
}
source
share