I have a class that implements comparable as shown in its signature:
public class PairNode<FirstType, SecondType> implements Comparable
This class compiles fine, and has a proper compareTo method.
In another class, it's constructor takes an ArrayList of comparable object in it's constructor, as shown here:
public HeapMinPriorityQueue(ArrayList<Comparable> list)
However, when later on, when I have an ArrayList of PairNodes, and I try to use the constructor like this:
HeapMinPriorityQueue pq = new HeapMinPriorityQueue(list);
Java tells me that they are incompatible types, as an ArrayList of PairNodes of Characters and Integers can't be converted to an ArrayList of Comparables. But shouldn't they be equivalent, as my PairNode implements Comparable?
Assylias answered this for me by posting a link, but Generic types aren't polymorphic, and therefore that was why it wasn't working. I am changing my class to specific version to remedy this. Thank you assylias!