Student\'s names(String[]) and corresponding marks(int[]) are stored in different arrays.
How may I iterate over both arrays together using for each loop in Java ? <
The underlying problem is actually that you should tie both of the arrays together and iterate across just one array.
Here is a VERY simplistic demonstration - you should use getters and setters and you should also use a List
instead of an array but this demonstrates the point:
class Student {
String name;
int mark;
}
Student[] students = new Student[10];
for (Student s : students) {
...
}