Posted on 2010-10-11 12:55
セ军魂ミ 阅读(112)
评论(0) 编辑 收藏
public static void main(String[]args){
Student[] stuArr = new Student[10];
//student1
Student student1 = new Student();
student1.setName("张三");
student1.setDepartment("二班");
student1.setAge(18);
student1.setScore(2);
//student1.setLavel("B");
stuArr[0] = student1;
//student2
Student student2 = new Student();
student2.setName("李四");
student2.setDepartment("三班");
student2.setAge(20);
student2.setScore(3);
//student2.setLavel("D");
stuArr[1] = student2;
//student3
Student student3 = new Student();
student3.setName("王五");
student3.setDepartment("一班");
student3.setAge(21);
student3.setScore(5);
//student3.setLavel("A");
stuArr[2] = student3;
//student4
Student student4 = new Student();
student4.setName("钱六");
student4.setDepartment("二班");
student4.setAge(22);
student4.setScore(1);
//student4.setLavel("C");
stuArr[3] = student4;
for(int i=0;i<stuArr.length;i++){
if(stuArr[i]!=null){
int s =stuArr[i].getScore();
if(s==5){
System.out.println("A");
}else if(s==4 ){
System.out.println("B");
}else if(s==3){
System.out.println("C");
}else if(s==2){
System.out.println("D");
}else if(s==1){
System.out.println("E");
}
else{
System.out.println("F");
}
System.out.println(stuArr[i].getName()+"---"+stuArr[i].getDepartment()+"---"+stuArr[i].getAge()+"---"+stuArr[i].getScore());
}
else{
System.out.println("这个对象为null");
}
}