this.courses = new HashSet<Course>(); 這句不理解呀
public class Student {
public String id;
public String name;
public Set<Course> courses;
public Student(String id, String name) {
this.id = id;
this.name = name;
this.courses = new HashSet<Course>();
}
}
2016-03-15
第三行聲明了courses是Set接口泛型為Course的引用
this.courses = new HashSet<Course>();
this表示當(dāng)前類,this.courses即當(dāng)前類的courses屬性 ?
new HashSet<Course>() 實例化一個HashSet類型的對象,HashSet是Set接口的一個實現(xiàn)類
大概就是這樣
2016-03-15
為代碼第三行的Courses變量,進(jìn)行創(chuàng)建?