student.java
package com;
public class Student {
private int id;
private String name;
private int classRate;
public int getId() {
return id;
}
public String getName() {
return name;
}
public int getClassRate() {
return classRate;
}
public Student(int id, String name, int classRate) {
this.id = id;
this.name = name;
this.classRate = classRate;
}
}
package com;
import java.util.ArrayList;
import java.util.List;
public class Slist {
public static void main(String[] args) {
Student st1 = new Student(1, "wangxu", 98);
Student st2 = new Student(2, "zhanghong", 100);
List<Student> stus = new ArrayList<Student>();
stus.add(st1);
stus.add(st2);
System.out.println(st1.getName());
}
}