public static ArrayList<Integer> getStudentClasses(Student student, ArrayList<Integer>[] classesXstudents) {
ArrayList<Integer> classes = new ArrayList<Integer>();
for (int i = 0; i < classesXstudents.length; i++) {
for (int j = 0; j < classesXstudents[i].size(); j++) {
if (classesXstudents[i].get(j) == student.getID()) {
classes.add(i+1);
}
}
}
return classes;
}
throws NullPointerException at the line
for (int j = 0; j < classesXstudents[i].size(); j++) {
which I'm assuming means classesXstudents[i].size() is null at some point. classesXstudents is an array of ArrayList objects. How should I debug this case?