I’m trying to compile my project but I get the following error:
“error: type argument Process is not within bounds of type-variable T”
public class Heap<T extends Comparable<T>> {
// ...
}
public class Process {
// ...
}
public class HeapDemo{
public static void main(final String[] args) {
Heap<Process> heap = new Heap<Process>(); //error here
}
}
The program is a CPU scheduling simulation using heaps, if that helps any.
The reason that you get the error is that
Processdoes not implementComparable<Process>, a condition that must be met by all classes that you supply as type arguments toHeap<T>because of a type constraint that you placed on your generic type.