backward list iteration using iterator

后端 未结 1 857
梦毁少年i
梦毁少年i 2021-01-28 07:34

here its a code about listiterator. Work properly in forward direction but when its come to iterate in backward it goes into infinite loop. after every element print i put a

相关标签:
1条回答
  • 2021-01-28 08:20

    ListIterator is kind of cursor, that points to some element. Methods ListIterator.next() and ListIterator.previous() move this cursor to another element, so your code moves it forward and backward repeatedly, that causes infinite loop.

    0 讨论(0)
提交回复
热议问题