Using inheritance with ArrayList

Try

void test(ArrayList<? extends ObjectType1> object) {

and welcome to the weird world of Java generics! :stuck_out_tongue_winking_eye:

Inheritance doesn’t work the same way with generics - see Generics, Inheritance, and Subtypes (The Java™ Tutorials > Learning the Java Language > Generics (Updated))

4 Likes