A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

© ZhengJX 中级黑马   /  2015-10-10 22:48  /  413 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

  1. package com.heima.zuoye;

  2. import java.util.ArrayList;
  3. import java.util.Iterator;

  4. import com.heima.bean.Person;

  5. public class Demo3_Generic {
  6.         public static void main(String[] args) {
  7.                 ArrayList<Person> list = new ArrayList<>();
  8.                 list.add(new Person("张三",23));
  9.                 list.add(new Person("李四",24));
  10.                 list.add(new Person("王五",25));
  11.                 list.add(new Person("赵六",26));
  12.                
  13.                 Iterator<Person> i = list.iterator();
  14.                 while(i.hasNext()) {
  15.                         Person p = i.next();
  16.                         System.out.println(p.getName()+".."+p.getAge());
  17.                         //System.out.println(i.next());
  18.                 }
  19.         }
  20. }
复制代码


1 个回复

倒序浏览
66666666666,今儿刚学完泛型,正好复习
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马