print(1);
public static void print(Integer i) {
System.out.println("This is an Integer");
}
or
public static void print(double i) {
System.out.println("This is a double");
}
why it is calling double parameter instead of Integer. I thought it will call Integer parameter due to autoboxing.help me understand this
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Anonymous #10410173 Full Stack Developer
9 August 2020, 20:15
0
Ed Maphis
5 June 2019, 22:56
I don't know for sure, but I'll guess the Java compiler wide casts up the numerical hierarchy before it casts to the Object hierarchy.
0