I have a class B that contains these four methods:
public class B {
public void f(int x) {
System.out.println("1");
}
public void f(Object x) {
System.out.println("2");
}
public void f(List x) {
System.out.println("3");
}
public void f(Collection x){
System.out.println("4");
}
and in the main I have these commands:
B o = new B();
Integer n = new Integer(3);
List<Integer> l = new ArrayList<>();
Collection<Integer> m = new ArrayList<>();
o.f(3);
o.f(n);
o.f(l);
o.f(m);
The result will be:
1
2
3
4
why does "3" considered as int while Integer(3) concidered as Object? And why List or Collection isn't considered as Object?