I have a little problem connected with interfaces, classes and generics in Java.
First of all, I have an interface which is meant to represent the idea of Priority Queue:
public interface PriorityQueue<T> {
// insert object o of class T into priority queue with appropriate element
public void insert(T o);
// remove an element with the highest priority
public T remove();
}
As we know we can implement a priority queue by heap or list. Here's my class of heap:
public class Heap <T implements Comparable> implements PriorityQueue<T>
I want to have an ArrayList which will have elements of type T. I want my heap to be prepared for all types which are comparable (classes which implement interface Comparable). T could be a String, Double, Integer or just my own type (then I know that I have to write a compareTo method...).
How can I do that? I have a lot of errors in my NetBeans...