Hi all,

I have a class I am implementing called a Deque. Deque has a method called ensureCapacity that increases the size of the array holding the deque automatically.

Here is the implementation of ensureCapacity:


public Deque ensureCapacity(Deque elementData){


Deque newElementData = newDeque (elementData.length*2);

int indexOffSet =( (newElementData.length()) - elementData.size() )/2;

System.arraycopy(elementData, front, newElementData, indexOffSet, elementData.size());

front = indexOffSet;

back = indexOffSet + elementData.size();

}//End of ensureCapacity




The call I use to the method is this:

elementData = ensureCapacity(elementData);


I would expect the method to return a new Deque with the old Deque inserted into the middle of the new array. However the compiler complains and says:

ensureCapacity(Deque) in Deque cannot be applied to (java.lang.Object[])

elementData = ensureCapacity(elementData);


What have I done wrong here? Thanks for any help.