Please take a look in my code as below:
Vector<Vector<String>> AllSubjects = new Vector<>() ; // PROBLEM IS HERE
if ((AllSubjects = EMSSubjectDAO.SelectAllSubjectsByCourse(this.ActiveCourse.getCourseID())) != null)
{
SubjectTableModel = new DefaultTableModel(AllSubjects, SubjectTableHeader);
SubjectTable.setModel(SubjectTableModel);
//this.SubjectTable = new JTable(AllSubjects, SubjectTableHeader) ;
}
On the // PROBLEM IS HERE
line, if I init Vector<Vector<String>> AllSubjects = new Vector<>() ;
, the new DefaultTableModel(AllSubjects, SubjectTableHeader);
will run fine.
But if I write Vector<Vector<String>> AllSubjects = null
, the new DefaultTableModel(AllSubjects, SubjectTableHeader);
will erase all data in AllSubjects
and nothing will be initialized
I really want to understand why this happen? I guess if we dont init Vector<Vector<String>>
properly, Java would not treat the object as expected, is it right?
Hope you guys can help me on this, thanks in advanced