為什么老師的代碼在我這里會出錯呢
jar包我也都考了,代碼完全一樣,怎么下面這兩行代碼老師不能執(zhí)行呢
g.getStudents().add(stu1);
g.getStudents().add(stu2);
Exception in thread "main" java.lang.NullPointerException
at com.imooc.test.Test.update(Test.java:64)
at com.imooc.test.Test.main(Test.java:21)
2016-02-19
空指針異常,應該是g對象為空,沒獲取到值
2016-05-06
private Set<Student> students ?=new HashSet<Student>();