using two iterators in one ArrayList

后端 未结 5 1292
遇见更好的自我
遇见更好的自我 2021-01-19 09:16

Edit: Thank you for all your prompt replies. Now I see the assignment won\'t work. From another thread I read that iterator in Java is much less powerful than iterator in C+

5条回答
  •  余生分开走
    2021-01-19 09:54

    It's valid, but it won't do what you want it to do. You'll still have only one iterator, and the outer loop will terminate after the inner one has terminated for the first time.

    Java iterators cannot be copied meaningfully. You'll have to use a simple for loop that increments indexes.

提交回复
热议问题