//集合类的作用 public class test35 { private String name; private int num; private int grade; public test35(String name,int num,int grade){ this.name=name; this.num=num; this.grade=grade; } public String getName() { return name; } public int getGrade() { return grade; } public int getNum() { return num; } } 测试import java.util.ArrayList; public class test36 { public static void main(String[] args){ ArrayList aa1=new ArrayList(); //当前对象个数 System.out.println("原始的对象个数为"+aa1.size()); test35 xs1=new test35("歌谣",3,4); aa1.add(xs1); System.out.println("现在的对象个数为"+aa1.size()); } }