Students tempStudent = new Students();
に変更します
Students tempStudent;
あなたはoverridding 同じオブジェクトのプロパティ tempStudentを作成してから 外部コード> whileループ 。 オブジェクトを追加する必要があります レコード数に等しい データベース内。したがって、tempStudentオブジェクトを作成します 以下のように。
使用
while (rs.next()) {
tempStudent = new Students();
tempStudent.studentId = rs.getInt("StudentNo");
tempStudent.studentName = rs.getString("StudentName");
tempStudent.studentAge = rs.getInt("StudentAge");
students.add(tempStudent);
size++;
}