问答详情
源自:6-8 学生选课--- 实现学生序列排序

public void testSort3()方法报错

public void testSort3(){

List<Student>studentList=new ArrayList<Student>();

Random random =new Random();

Integer k;

Integer k1;

Integer k2;

Integer k3;

for(int i=0;i<3;i++){

do{

k=random.nextInt(10);

}while(studentList.contains(k));

if(i==0){

k1=k;

}else if(i==1){

k2=k;

}else{

k3=k;

}

}

studentList.add(new Student(k1+"","Jike"));

studentList.add(new Student(k2+"","Angela"));

studentList.add(new Student(k3+"","Lucy"));

studentList.add(new Student(10000+"","Tom"));

为啥K1,k2,k3会报错?

提问者:moummm 2017-01-16 15:08

个回答