Java iterator over an empty collection of a parameterized type

后端 未结 7 1612
隐瞒了意图╮
隐瞒了意图╮ 2021-01-03 18:36

In Java, I need to return an Iterator from my method. My data comes from another object which usually can give me an iterator so I can just return that, but in some circums

7条回答
  •  自闭症患者
    2021-01-03 19:19

    You can get an empty list of type Foo through the following syntax:

    return Collections.emptyList().iterator();
    

提交回复
热议问题