lab3tester.jpg
lab3tester.jpg
As showed above, Default constructor and default constructor with given size gives OK. But when I run the iterator, nothing is shown for the output.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
lab3tester.jpg
lab3tester.jpg
As showed above, Default constructor and default constructor with given size gives OK. But when I run the iterator, nothing is shown for the output.
You need to add some println debugging code to see where the execution flow goes and what the values of the variables are as they are used and change. From your desk checking with paper and pencil you should know what the variables' values should be at each step so you can compare the printed output with what you expect the values to be and determine what is wrong with the code.nothing is shown for the output.
When I run your iterator, it works OK - although because the list acts more like a stack if you use insertItem, so the items I inserted came out of the iterator in reverse order of insertion.
I have to say that this 'SimpleComparableList' doesn't seem all that simple to me - the insertItem method seems counter-intuitive, and the currentPosition idea is a confusing complication - next() and prev() don't return the next and prev items, although the iterator next() does return the next item... YMMV.