黑马程序员技术交流社区
标题:
arraylist嵌套arraylist
[打印本页]
作者:
ZhengJX
时间:
2015-10-10 22:45
标题:
arraylist嵌套arraylist
package com.heima.zuoye;
import java.util.ArrayList;
import com.heima.bean.Person;
public class Demo5_DoubleList {
public static void main(String[] args) {
ArrayList<ArrayList<Person>> list = new ArrayList<>();
ArrayList<Person> first = new ArrayList<>();
first.add(new Person("金洋", 23));
first.add(new Person("文悦", 24));
ArrayList<Person> second = new ArrayList<>();
second.add(new Person("呵呵", 11));
second.add(new Person("哈哈", 10));
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