I am preparing for a SCJP exam and when studying widening part it\'s given that widening beats both Boxing and Var-args in overloading but there is no clear explanation. Tri
class Widen {
private static widen(long k) {
System.out.println("Converted to long: " + k);
}
private static widen(int ... k) {
System.out.println("Converted to varargs: " + k);
}
private static widen(Integer k) {
System.out.println("Converted to Integer: " + k);
}
public static void main(String ... args) {
int value = 3;
widen(value); // Output: Converted to long: 3
}
}
to solve above mind this:
widening beats boxing, boxing beats varargs
the out put will be Converted to long:3