moummm
2017-01-16 15:08
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会报错?
未初始化 =null;
Java入门第三季
409792 学习 · 4340 问题
相似问题
回答 1
回答 2