Implementing the Iterable interface

后端 未结 4 1891
星月不相逢
星月不相逢 2020-12-21 00:49

I just found this exam question in an old exam paper and am readying myself for an upcoming exam. I cannot figure it out :

The following depicts a contrived partial

4条回答
  •  离开以前
    2020-12-21 01:25

    Your Iterator must implement all the methods from the Iterator interface in order to encapsulate the iteration logic.

    In your case, it will have to hold the current iteration index in the array. You can look at ArrayIterator from commons-collections

提交回复
热议问题