Originally Posted by
andbin
1) [important] Your list is a "linked" list ..... but get(index) has to scan the linked list to find the item at that index! Remember that the iterator can (and should) have an "intimate" vision on the internal structure of the linked list. Thus the iterator should carry the iteration in the smart way .... not in the trivial way call-the-get-on-each-next.
I agree. Unfortunately we were asked to use existing methods.
I would write a method that scans till current index -1 or something, pretty much does the same but without using external method.
On the other hand we are asked to write it wisely so I guess I will still do it.
Originally Posted by
andbin
2) If you have used the "generics" in an appropriate and consistent way, the cast (E)get(index) is not necessary.
Seems Java asked to add casting, but I will look into it again, may be a leftover from my previous pathetic attempts.
Originally Posted by
andbin
3) If you don't want to implement remove() with the appropriate behaviour, you can leave it empty but generally it's more common and useful to throw a java.lang.UnsupportedOperationException just to signal that it's not supported.
3. Thank you, I will add it.
Thank you very much for the help