ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
集合类的概念 ![](https://box.kancloud.cn/f33c29a68086ce786e67bf233ccabbc8_965x312.png) 集合类的分类 ![](https://box.kancloud.cn/dbe7711261954eacd428117359fba76f_602x312.png) ~~~ package a3; import java.util.ArrayList; public class Test { public static void main(String[] args) { ArrayList aa1= new ArrayList(); System.out.println("大小为"+aa1.size());//大小为0 } } ~~~ ~~~ package a3; import java.util.ArrayList; public class Test { public static void main(String[] args) { ArrayList aa1= new ArrayList(); Xs xs1= new Xs("悟空",15,90); aa1.add(xs1); System.out.println("大小为"+aa1.size());//大小为1 } } class Xs{ private String xingming; private int xuehao; private int chengji; Xs(String xingming, int xuehao, int chengji) { this.xingming = xingming; this.xuehao = xuehao; this.chengji = chengji; } public String getXingming() { return xingming; } public void setXingming(String xingming) { this.xingming = xingming; } public int getXuehao() { return xuehao; } public void setXuehao(int xuehao) { this.xuehao = xuehao; } public int getChengji() { return chengji; } public void setChengji(int chengji) { this.chengji = chengji; } } ~~~ 如上,就完成了创建集合及添加数据,集合的大小从0变成了1