Avoid index out of bound for static methods with array params