public class Tester { static void call(Long x, Long y) { System.out.print("Long x, Long y"); } static void call(int... x) { System.out.print("int... x"); } static void call(Number x, Number y) { System.out.print("Number x, Number y"); } public static void main(String[] args) { int val = 3; call(val, val); } }
static void call(Long x, Long y) {
System.out.print("Long x, Long y");
}
static void call(int... x) {
System.out.print("int... x");
static void call(Number x, Number y) {
System.out.print("Number x, Number y");
public static void main(String[] args) {
int val = 3;
call(val, val);
You cannot widen then autobox (cannot widen from int to long then autobox to Long), BUT you can autobox then widen (autobox to Integer then widen to Number, Integer extends Number) therefore “Number x, Number y” is printed
Oracle Certified Professional Java Programmer
Access: Public Instant Grading
Jobilize.com uses cookies to ensure that you get the best experience. By continuing to use Jobilize.com web-site, you agree to the Terms of Use.