This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Very good question! I really had to think about it. It's because the T in asList(T... a) can only be an object and not a primitive.
But the int is an object (arrays extend object) therefor it does compile and it returns List<int>. I'm surprised there aren't overloaded methods available for primitives because other methods in the Arrays class do have them.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
The algorithm used by the compiler for the resolution of overloaded methods
incorporates the following phases:
1. It first performs overload resolution without permitting boxing, unboxing, or
the use of a varargs call.
2. If phase (1) fails, it performs overload resolution allowing boxing and unboxing,
but excluding the use of a varargs call.
3. If phase (2) fails, it performs overload resolution combining a varargs call,
boxing, and unboxing.
Source : Book By
Khalid A. Mughal
Rolf W. Rasmussen