💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
~~~ 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); Xs xs2= new Xs("八戒",13,70); Xs xs3= new Xs("沙僧",14,80); aa1.add(xs1); aa1.add(xs2); aa1.add(xs3); //System.out.println("大小为"+aa1.size()); for(int i=0;i<aa1.size();i++){ Xs tv =(Xs)aa1.get(i); System.out.println("第"+(i+1)+"个学生的姓名是"+tv.getXingming()); } } } 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; } } ~~~ ![](https://box.kancloud.cn/c6a3abec75a76341a625e5a33b8ed919_420x170.png)