public class MaxHeap<T extends Comparable<T>> implements Heap<T>{
private T[] heap;
private int lastIndex;
private static final int defaultInitialCapacity = 25;
public void add(T newItem) throws HeapException{
if (lastIndex < Max_Heap){
heap[lastIndex] = newItem;
int place = lastIndex;
int parent = (place – 1)/2; //ERROR HERE**********
while ( (parent >=0) && (heap[place].compareTo(heap[parent])>0)){
T temp = heap[place];
heap[place] = heap[parent];
heap[parent] = temp;
place = parent;
parent = (place-1)/2;
}else {
throw new HeapException("HeapException: Heap full"); }
}
}
Eclipse complains that there is a:
"Syntax error on token "Invalid Character", invalid AssignmentOperator"
With the red line beneath the (place-1)
There shouldn't be an error at all since it's just straight-forward arithmetic. Or is it not that simple?