美文网首页
IteratorCollection

IteratorCollection

作者: 勇者与王者 | 来源:发表于2019-09-28 16:13 被阅读0次
package generic;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import objectAndClass.Hero;

/**
* 
* @author q06285:
* @version 创建时间:2019年9月27日 下午5:14:32
* 
*/
public class IteratorCollection {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        List<Hero> heros = new ArrayList<>();
        
        for (int i = 0 ; i < 5; i++) {
            heros.add(new Hero("hero "+i));
            
        }
        
        Iterator<Hero> it = heros.iterator();
        
        while (it.hasNext()) {
            Hero h = it.next();
            System.out.println(h);
        }
        
        System.out.println("---------");
        
        
        
    }

}

相关文章

网友评论

      本文标题:IteratorCollection

      本文链接:https://www.haomeiwen.com/subject/daktpctx.html