ArrayList嵌套ArrayList,arraylist嵌套
ArrayList嵌套ArrayList,arraylist嵌套
import java.util.ArrayList;
import com.heima.bean.Person;
/**
* @author 作者 HouQiang:
* @version 创建时间:2017年5月12日 下午4:00:27
* 类说明
*/
public class Demo3_ArrayListArrayList {
public static void main(String[] args) {
ArrayList<ArrayList<Person>> list=new ArrayList<>();
ArrayList<Person> first=new ArrayList<>();
first.add(new Person("吴京",43));
first.add(new Person("李连杰",50));
first.add(new Person("甄子丹",45));
ArrayList<Person> second=new ArrayList<>();
second.add(new Person("孙俪",41));
second.add(new Person("李冰冰",42));
second.add(new Person("娄艺潇",27));
list.add(first);
list.add(second);
for (ArrayList<Person> arr : list) {
System.out.println(arr);
}
System.out.println("---------------");
for (ArrayList<Person> arr2: list) {
for (Person person : arr2) {
System.out.println(person);
}
}
}
}
相关文章
- 暂无相关文章
用户点评