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.
03-05-2003, 08:13 AM
Well, I don't know too much about increasing sizes of arrays and things like that, but the error message you got means that you cannot use that class to increase the size of an array for an object. Maybe if you try to pass the Deque instead as an array of integers it might work. What exactly does the Deque object hold? Maybe there's a better way of doing it... Hope this helps!
03-17-2003, 02:26 PM
Check what type of variable elementData is. From the compile error I'm guessing it's an array. This will not work as the method expects a single reference.
03-19-2003, 05:02 AM
if you want to change the size of an array, you might wanna try using the Vector class. it's an unlimited array.
you can read about it somewhere in the beginner tutorials here in the site which is called "java by example"
03-19-2003, 05:20 AM
...or java.util.ArrayList. It's more efficient than Vector (it's all to do with synchronzing in multi-threaded code).