I have two ArrayLists that contain Parent and Child class which Child extents Parent and Second extends First
public First(ArrayList<Parent> parents)
{
// Parent Class's constructor
}
second class's constructor
public Second(ArrayList<Child> child)
{
super(child);
// child class's constructor take ArrayList<Child>
}
Is it possible to cast ArrayList<Child> to ArrayList<Parent>?
ArrayList<? extends Parent>?ArrayList<? extends Parent>, perhaps? It's not really clear what you want to do. Do you want to pass an ArrayList of Child to First?Secondwhich is able to takeArrayList<Child>. AsParentandChild,FirstandSecondare quite similar, so I am looking for a way to subclass them.