I have started learing java generics and this is my priority queue implementation:
public class MinPQ<Key> implements Iterable<Key> {
private Key[] pq; // store items at indices 1 to n
private int n; // number of items on priority queue
private Comparator<Key> comparator; // optional comparator
public MinPQ(Key[] keys) {
n = keys.length;
pq = (Key[]) new Object[keys.length + 1];
.....
.....
}
}
And this is my main class :
public class Demo {
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] ar = {1,2,3};
MinPQ<Integer> pq = new MinPQ<Integer>(ar);
}
}
But here I get an error stating "The constructor MinPQ(int[]) is undefined" can someone please help me find the issue here ?