- 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);
- }
- }
- }
- }
复制代码 |
|