What is the Iterable interface used for?

前端 未结 5 1165
执念已碎
执念已碎 2020-12-08 10:01

I am a beginner and I cannot understand the real effect of the Iterable interface.

5条回答
  •  盖世英雄少女心
    2020-12-08 10:19

    An interface is at its heart a list of methods that a class should implement. The iterable interface is very simple -- there is only one method to implement: Iterator(). When a class implements the Iterable interface, it is telling other classes that you can get an Iterator object to use to iterate over (i.e., traverse) the data in the object.

提交回复
热议问题