Loop through the array and then follow your logic. I assume that Course
contains a list named students
, from which you need to know if their chosenPathWay
is "maths".
yourArray
is the array that holds all Courses.
List<Student> matchingStudents=new ArrayList<Student>();
for (int i=0;i<yourArray.length();i++)
{
Course c = yourArray[i];
for (Student student: c.students)
if (student.chosenPathway.equalsIgnoreCase(requiredPath)) //requiredPath = "maths"
matchingStudents.add(student);
}
The code above assumes you must store all students that match the criteria. If you only need to know wether a Course has an student whose path is maths, just:
List<Course> matchingCourses =new ArrayList<>();
for (int i=0;i<yourArray.length();i++)
{
Course c = yourArray[i];
for (Student student: c.students)
if (student.chosenPathway.equalsIgnoreCase(requiredPath)) //requiredPath="maths"
{
matchingCourses.add(c);
break; //finish looping through this course
}
}