首先,Student类的构造方法是这样的:
public Student(String id,String name){
this.id=id;
this.name=name;
this.courses=new HashSet<Course>();
}
然后在测试类中,有这样一个方法:
public void testSort3(){
List<Student> studentList=new ArrayList();
studentList.add(new Student(1+"","小明"));
studentList.add(new Student(2+"","小红"));
studentList.add(new Student(3+"","小兰"));
}
为什么在这个方法中,创建Student对象时,参数中会多了一个+号和一个“”?
慕圣0830664
相关分类