You are making things too difficult for yourself.
Well, actually, you will have no real problems. That array, being nicely set to null, will throw a load of nice Exceptions whenever you try to use it You should delete that array, and use the same array which is already a field in the surrounding class.
You will need an int called size which should be set in the surrounding class already. You need to use that in the hasNext method
The remove() method should remove. If you are dealing with an array, you would have to reduce the rest of the array:In the else part of the next() method, you throw the NoSuchElementException.
At least I think that is what you do. Anybody finding any mistakes (especially Joanne and Rob), be sure to tell me. But I am off to cook tea now, so I shan't take any notice.
Joined: Aug 05, 2005
Campbell Ritchie wrote:But I am off to cook tea now, so I shan't take any notice.
It's Friday, and I am very conventional, so it's fish. Some salmon and some sea-bass, baked in the oven with onions tomatoes and herbs. And I would have added mushrooms if I'd remembered to buy some. And runner beans and new potatoes. The tomatoes were quite old; they had been off the plant for a good 10 minutes before they were cooked.