Java iterator over an empty collection of a parameterized type

后端 未结 7 1521
隐瞒了意图╮
隐瞒了意图╮ 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:17

    The annoyance of Collections.emptyList().iterator() is the main reason we provide Iterators.emptyIterator() in google-collections. No type parameter needed, in cases like yours.

提交回复
热议问题