Possible Duplicate:
Implementations and Collections
My super class is Exam. One of my sub classes is Analytical.
This is a valid within my ide
Exam object = new Analytical();
However this is not.
ArrayList<Exam> object = new ArrayList<Analytical>();
The error is from new to the end of the statement and it says “Change type of object to ArrayList. So my question is how can I properly utilize polymorphis with this data structure. Thank you.
You cannot have different parameterized types on two sides of generic type declaration..
So, you must use the same type on both side..
It should be: –
or
or
Polymorphism, does not apply on the parameterized type..