Treat Enumeration as Iterator

前端 未结 7 2162
感动是毒
感动是毒 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 02:50

    There's nothing that is part of the standard library. Unfortunately you'll have to roll your own adapter. There are examples out there of what others have done, for example:

    IterableEnumerator

提交回复
热议问题