Have you posted the offending code exactly as it was run? Because what you wrote won't throw any exceptions. What you wanted to write, viz swap(Arrays.asList(ar1), 1, 0); will however throw an exception. If you look through the Arrays class, you will find the asList() method, but you won't find any overloadings for it. It takes T... as a parameter and ints cannot be a T. If you pass an Integer, the method can take Integer as its T, but if you pass an int or any other array of primitives, it can only take int or similar as its type. So you create a List<int]> with one element.