Can someone explain this to me
List<Integer> list = new LinkedList<Integer>();
list.add(2);
list.add(1);
list.add(3);
when i used
list.remove(1);
then the 1st element is deleted
list.remove(new Integer("1"));
then the 2nd element is deleted.
So you can explain the behavior of automatic boxing and unboxing in the above scenario
when new A().a(new Integer("1"));
performed,
public class A {
public void test(Integer i) {}
public void test(int i) {}
public void test(Object o) {}
}
method 1 is executed
public class A {
public void test(int i) {}
public void test(Object o) {}
}
method 3 adopted
source
share