Type a call showing widening wins over autoboxing in overload resolution
Type a call showing widening wins over autoboxing in overload resolution
Answer
void print(long x) { System.out.println("long"); } void print(Integer x) { System.out.println("Integer"); } // print(5) prints "long" — widening before boxing
Java resolves to the widening overload (long) rather than the boxing overload (Integer) because widening is preferred. The resolution order is: exact match, then widen, then box, then varargs.