I have one doubt on generics implementation on below code,
class A {
    public void print(List obj) {
    }
    public static void main(String args[]) {
        ClassA aObj = new ClassA();
        List<String> strList = new ArrayList<String>();
        strList.add("ABC");
        aObj.print(strList); // Complile time error
    }
}
Why I am getting complie time error. I know, to avoid the type casting or runtime ClassCastException, jdk 1.5 introduces generics but in above piece of code, I simply thought of parent-child concept and tried to pass List of String instead of Object. Then why I am getting the compile time error.
Justification Of my question Let's suppose, if I write the same above piece of code like,
class A {
    public void print(Object obj) {
    }
    public static void main(String args[]) {
        ClassA aObj = new ClassA();
        aObj.print("ABC"); // Vallid
    }
}
Its Works!!
Please help me to get out of here. Thanks.
 
     
     
     
    