Accessing methods of objects stored in an ArrayList
Title basically says it all...
I've got a class and a class nested inside that one, the outer class has an ArrayList object that stores objects of the nested class, and the objects of the nested class have their own ArrayList objects, and need to access/retrieve members of the inner classes' ArrayList objects, but don't know how.
Now the code, then more clarification.
Okay. So each ClassList has an ArrayList of students, and each student has an ArrayList of grades.
private String name;
private ArrayList grades;
private double mean;
public Student(String n, int g1, int g2, int g3, int g4)
name = n;
grades = new ArrayList();
private ArrayList students;
private int studentCount;
private ArrayList testMean;
private int testCount;
private double classMean;
students = new ArrayList();
testMean = new ArrayList();
studentCount = 0;
testCount = 4;
Assorted blank method stubs that will be filled in with accessing and setting commands, once I figure out how to access the inner array values.
Also a method that reads a .txt file and populates the ClassList arrayList of students and the student ArrayList of grades with values.
I can access each student object in the classList ArrayList, but I can only retrieve its memory address. I do not know how to access any values of the student objects' ArrayLists (which are stored in the ClassList arrayList and must be accessed from there).
Final attempt at explaining the problem: How the heck would I retrieve all the grades of a given student knowing only its index in the ClassList ArrayList?
Any help would be much appreciated. Thanks in advance.
Last edited by Gengar003; 05-09-2005 at 11:36 AM.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center