Arrays.copyOfRange method in java throws incorrect exception
问题 I was working on arrays today and suddenly I came across a scenario throwing unexpected exceptions. If you look at the code below , I think it must throw ArrayIndexOutOfBoundsException , but surprisingly it is throwing IllegalArgumentException instead: import java.util.Arrays; public class RangeTest { public static void main(String[] args) { int[] a = new int[] {0,1,2,3,4,5,6,7,8,9}; int[] b = Arrays.copyOfRange(a, Integer.MIN_VALUE, 10); // If we'll use Integer.MIN_VALUE+100 instead Integer