I have a custom “Heap” class:
public class Heap<T extends Comparable<T>>
{
ArrayList<T> heapList;
public Heap()
{
heapList = new ArrayList<T>();
}
and a custom “Process” class:
public class Process {
private int processID, timeUnitsRequired, priority, timeOfArrival;
public Process(int processID, int timeUnitsRequired, int priority, int timeOfArrival) {
this.processID = processID;
this.timeUnitsRequired = timeUnitsRequired;
this.priority = priority;
this.timeOfArrival = timeOfArrival;
}
But if I try to make a new Heap of Processes, like Heap<Process> processHeap = new Heap<Process>(); I get the following error:
Bound mismatch: The type Process is not a valid substitute for the bounded parameter > of the type Heap
Why is this? I can’t seem to figure it out.
The process object needs to implement the
Comparableinterface.Example Implementation Comparing by Priority
Comparable API Documentation