How to use the same iterator again and again?

前端 未结 3 1685
攒了一身酷
攒了一身酷 2020-12-21 07:16

Given the next code :

// this is a part of some large method //

        ArrayList players = this.m_maze.getPlayers();

    // define          


        
3条回答
  •  伪装坚强ぢ
    2020-12-21 08:06

    If you want to reuse the iterator, you have to re-initialise it.

    You have to execute Iterator iterator = players.iterator(); whenever you want to reuse the iterator.

提交回复
热议问题