public class DateDemo {
public static void main(String[] args) {
java.util.Vectorvs = new java.util.Vector ();
for(int i = 0; i < 10; i++){
vs.add(new Student(i,"张三"+i,"男",+1.72,65.03));
}
java.util.Iteratorit = vs.iterator();
while(it.hasNext()){
System.out.println("---------------------------------");
Student st = it.next();
System.out.println("序号:" + st.num);
System.out.println("姓名:" + st.name);
System.out.println("性别:" + st.sex);
System.out.println("身高:" + st.shenggao);
System.out.println("平均成绩:" + st.pjcj);
}
}
}
class Student{
public int num;
public String name;
public String sex;
public double shenggao;
public double pjcj;
public Student(int num, String name, String sex, double shenggao, double pjcj){
this.num = num;
this.name = name;
this.sex = sex;
this.shenggao = shenggao;
this.pjcj = pjcj;
}
}
Public Class Student{
int number;
String name;
String sex;
int hight;
double weight;
double chengJi;
get set 方法
}
public Class Demo{
public static void main(String args[]){
Studeng st = new Student();
Array arr = new ArrayList();
arr.add(st);
}
}
这种问题就别提问了!你自己看看API就能搞定,API上面说的很清楚,相信自己能搞定.