Aj Prieto wrote:If I have a list that contains (1, 2, 3) and I start the iterator at index 3, this is what my code outputsThe values in the  were inputted by me as to what is expected. Is my thinking correct or are my expected values wrong?
Well, there's more than one way to do it, and it would actually be better if you showed us ALL the code for the class, especially the fields you're using.
It's also a bit difficult to understand your output, but I would remind you that Java List and array indexes are 0-BASED.
However, the general idea is this:
If you're starting with an index that is outside the bounds (as 3 is for an array of size 3), then just treat it as 'exclusive' (ie, each call to hasPrevious()/previous() checks or returns the element before the 'current' index.
So, assuming you have a 'currentIndex' field, hasPrevious() might look something like:
return currentIndex > 0 && currentIndex <= list.size();
remove() is a bit trickier, but it's usually supposed to remove the current element, so you generally don't need to update any indexes. The same with set() I believe: it simply inserts a value at the current index.
The real tricky part comes in combininghasPrevious()/previous() and hasNext()/next(), but it doesn't appear that you need to worry about that yet.
Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
Please do not remove code from, or alter, old posts. That makes the remainder of the thread incomprehensible.
If you think somebody has plagiarised your code, your college will find that because there is software which trawls the internet looking for similar code. I am sure it will find the code in your post.
I think little will be gained from further discussion, and am closing this discussion.