For some reason, my sortByDuration method will not let me call my remove method to print out the items in my heap as they are being deleted. The purpose of this is just to sort the heap; it really doesn't matter that I am deleting it.
public static Song[] sortByDuration(Song[] songs)//sorts the heap
{
for(int i=size;i>0;i--)
System.out.print(songs.remove()+" ");
return songs;
}
and this is my remove method
public Song remove()//removes
{
Song retVal = peek();
heap[0] = heap[size-1];
heap[size-1] = null;
size--;
bubbleDown();
return retVal;
}
the error is in the print statement of my remove method Thanks guys