previous in List Iterator of Java

前端 未结 1 1728
天涯浪人
天涯浪人 2021-01-29 09:53

I use the list iterator of Java, and I don\'t understand how does the previous method work. I get the next element of the Linked list \"B\" and then I try to get the previous el

相关标签:
1条回答
  • 2021-01-29 10:23

    From JavaDocs:

    Returns the previous element in the list and moves the cursor position backwards. This method may be called repeatedly to iterate through the list backwards, or intermixed with calls to next to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)

    Important part here is: (Note that alternating calls to next and previous will return the same element repeatedly.)

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