C#:iterator 迭代器/partial class 分布类/泛型 iterator 迭代器 写个最简单的迭代,(迭代一个字符串数组): 1.实现接口中的方法: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 using System.Collections; //动态数组是在这个命名
java.util.Iterator 迭代器iterator,是一个接口,不能够直接使用,需要使用Iterator接口的实现类对象,而获取实现类的的对象的方式为: Collection接口中有一个方法iterator(),因为Collection接口是List接口和Set接口的父接口,因此单列集合都是可以使用这个方法获得迭代器,这个方法返回的是迭代器的实现类对象 Iterator iterator() 两个常用的方法: boolean hasNext():判断集合是否还要下一个元素 E next