I am trying to write a PriorityQueue which must be genericized to a Comparable. Here is the constructor:
public class DavidiArrayPriorityQueue <E extends Comparable<E>> implements PriorityQueue<E> {
private E data[];
private int numElements;
//creates an empty priority queue with 10 spaces by default
public DavidiArrayPriorityQueue(){
data= (E[]) new Object[20];
numElements=0;
}
When I initialize it with
DavidiArrayPriorityQueue<Integer> test=new DavidiArrayPriorityQueue<Integer>();
It throws [Ljava.lang.Object; cannot be cast to [Ljava.lang.Comparable;
Objectis not aComparable.Object[]is not aComparable[].