Treat Enumeration as Iterator

前端 未结 7 2361
感动是毒
感动是毒 2021-01-04 02:22

I have a class that implements the Enumeration interface, but Java\'s foreach loop requires the Iterator interface. Is there an <

7条回答
  •  庸人自扰
    2021-01-04 03:01

    No need to roll your own. Look at Google's Guava library. Specifically

    Iterators.forEnumeration()
    

提交回复
热议问题