增加学生年龄和成绩
package first;
//学生集合类
public class three {
one [] xsong=new one[41];
//增加学生信息——————给数组赋值
public void add(one xs) {//one xs 代表一个学生的信息
for(int i=0;i<xsong.length;i++) {
if(xsong[i]==null) {
xsong[i]=xs;
break;
}
}
}
//输出学生信息——————输出数组
public void see() {
for(int i=0;i<xsong.length;i++) {
xsong[i].show();
}
}
}
package first;
//测试类
public class two {
public static void main(String[] args) {
//一个学生的信息
one b=new one();
b.id="1";
b.name="张三";
b.age=20;
b.score=80;
one n=new one();
n.id="1";
n.name="李四";
n.age=20;
n.score=60;
three c=new three();
c.add(b);
c.add(n);
c.see();
}
}