I am attempting to implement a Generic Heap. To insert the data I must compare the array for position. When I had this as only integers i was able to use this
while (heap[getParent(currentItem)] > heap[currentItem]) {
Converting to Generics I researched and attempted this:
while (heap[getParent(currentItem)].compareTo(heap[currentItem]) < 0) {
This was unsuccessful as it gives a NullPointerException. How can I convert the code to properly compare the items?