Is it possible for an ArrayList to return a list of superclass objects?
For example:
Class B extends Class A.
I have an ArrayList of Class B.
How do I use Java 8 to return an ArrayList of objects of Class A?
Eg:
class ClassA {}
class ClassB extends ClassA{}
I have a list of ClassB called classBList. I want to get a list of ClassA objects.
List <ClassA> classAList = new ArrayList <ClassA> (classBList);
But I am still getting ClassB in classAList.
Please help. Thanks.