為什么要在構造器中初始化students屬性
/**
* 用來承裝學生類型對象
*/
public Map<String, Student> students;
/**
* 在構造器中初始化students屬性
*/
public MapTest() {
this.students = new HashMap<String, Student>();
}
可以直接這樣做嗎?
public Map<String, Student> students =new HashMap<String, Student>();
2016-04-01
我覺的可以 。。
2016-04-22
一樣,很多人都在小DEMO中直接用
2016-04-18
不可以,不能直接實例化。