I'm playing with generic and I have a code that I can't undestand.
public static void main(String[] args) {
ArrayList<Integer> list=new ArrayList<Integer>();
list.add(1);
System.out.println(list);
t(list);
System.out.println(list);
}
static void t(List list){
list.add("test2");
list.add(3);
}
So, it's compiled and it works. I understand why the method t works .But I can realize why it is added to the main list which has stric generic type. Thanks