Yes, the a b b b c
output is the expected behavior.
Java's ListIterator.previous()
documentation explicitly says:
Note that alternating calls to
next
andprevious
will return the same element repeatedly.
The previous()
call is supposed to return b
. The main documentation for ListIterator
explains how it works, so read that to learn why.
The code is working as designed.