How do I put two different objects from two different classes which inherit from the same super class in one single array list?
List<Parent> listValue = new ArrayList<Parent>();
listValue.add(new Child1());
listValue.add(new Child2());
Both Child1 and Child2 are inherited from "Parent" Class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With