the following method returns output : in primitive int arg method
public class TestMethodOverloading {
private void show(int a){
System.out.println("in primitive int arg method");
}
private void show(float a){
System.out.println("in primitive float arg method");
}
public static void main(String[] args) {
TestMethodOverloading tmo = new TestMethodOverloading();
tmo.show(4);
}
}
Whereas if i change the arguement type of show method from int to Integer then output returned as : in primitive float arg method
public class TestMethodOverloading {
private void show(Integer a){
System.out.println("in Integer arg method");
}
private void show(float a){
System.out.println("in primitive float arg method");
}
public static void main(String[] args) {
TestMethodOverloading tmo = new TestMethodOverloading();
tmo.show(4);
}
}
But now if i change the arguement type of second method from float to Float then output again changes to : in Integer arg method
public class TestMethodOverloading {
private void show(Integer a){
System.out.println("in Integer arg method");
}
private void show(Float a){
System.out.println("in primitive float arg method");
}
public static void main(String[] args) {
TestMethodOverloading tmo = new TestMethodOverloading();
tmo.show(4);
}
}
Can anyone help me to understand this behavior