class Animal {
public void test(List<Integer> list) { };
public void test(List<String> list) { }; // compile error
}
class Animal {
}
class Dog extends Animal {
}
class Cat extends Animal {
}
public static void main(String[] args) {
Animal a = new Animal();
Dog b = new Dog();
ArrayList<Animal> la = new ArrayList<Animal>();
ArrayList<Dog> lb = new ArrayList<Dog>();
la = lb; // compile error
lb = la; // compile error
}
refer: http://tutorials.jenkov.com/java-generics/wildcards.html