学习笔记,仅供参考,有错必纠
package com.guiyang.object;
import java.sql.Array;
import java.util.ArrayList;
import com.guiyang.bean.People;
public class Demo5_ArrayListArrayList {
public static void main(String[] args) {
ArrayList<ArrayList<People>> list = new ArrayList<>();
ArrayList<People> first = new ArrayList<>();
first.add(new People("Ada", 21));
first.add(new People("Jack", 22));
first.add(new People("Petty", 19));
ArrayList<People> second = new ArrayList<>();
second.add(new People("小白", 18));
second.add(new People("小黑", 19));
list.add(first);
list.add(second);
for (ArrayList<People> arrayList : list) {
for (People people : arrayList) {
System.out.println(people);
}
}
}
}
输出:
People [name=Ada, age=21]
People [name=Jack, age=22]
People [name=Petty, age=19]
People [name=小白, age=18]
People [name=小黑, age=19]
本文地址:https://blog.csdn.net/m0_37422217/article/details/107241601
如对本文有疑问, 点击进行留言回复!!
荐 深入理解Java中的BigInteger和 BigDecimal,再也不怕面试了
tomact正常启动,但是在日志文件报错java.lang.NoClassDefFoundError: java/util/logging/Logger
servlet整合quartz:servlet中使用quartz,服务器启动时加载任务
荐 Java——集合中的Map接口通过HashMap类实现一些常用的方法
SpringBoot整合mybatis访问时报错Invalid bound statement (not found)
网友评论