黑马程序员技术交流社区

标题: 大明星班级 [打印本页]

作者: 林明辉    时间: 2016-4-21 22:53
标题: 大明星班级
package com.heima.list;

import java.util.ArrayList;

import com.heima.bean.Person;

public class Demo5_ArrayListArrayList {

       
        public static void main(String[] args) {
                ArrayList<ArrayList<Person>> list = new ArrayList<>();
               
                ArrayList<Person> first = new ArrayList<>();                               
                first.add(new Person("杨幂", 30));
                first.add(new Person("李冰冰", 33));
                first.add(new Person("范冰冰", 20));
               
                ArrayList<Person> second = new ArrayList<>();
                second.add(new Person("黄晓明", 31));
                second.add(new Person("赵薇", 33));
                second.add(new Person("陈坤", 32));
               
                list.add(first);
                list.add(second);
               
               
                for(ArrayList<Person> a : list) {
                        for(Person p : a) {
                                System.out.println(p);
                        }
                }
        }

}




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2