I have an Animal class and a Cat class which extends Animal (Cat is an Animal) I have defined a generic class:
public class Employee<T extends Animal> {
T obj;
Employee(T o){
obj=o;
}
String getName(Employee<T> a){
return "ok";
}
}
In a test class, if i write this, it gives me the following error error:
Employee<Cat> cat = new Employee<Cat>(null);
Employee<Animal> animal = new Employee<Animal>(null);
animal.getName(cat);
But if i give pass question mark for getName method, it works , i thought Cat is an Animal (Cat class extends Animal) . Any idea why i need to pass ? instead of T ?