So i'm in ap computer science right now and ArrayList are confusing the **** out of me.

We're working on a program in which we have to create a method that adds an "ap exam class" to an ArrayList heres what it looks like:

private ArrayList<APExam> myExams;

myExams = new ArrayList<APExam>();

* add an exam to myExams
public void addExam(APExam e)


any ideas? Thanks :)

2 Years
Discussion Span
Last Post by LiquidCloud
Featured Replies

Awesome it worked out! Simple ;p

but now im stuck on how to take all the ints in the arraylist and store it into 1 int:

     *  returns the student's average score on all exams
    public double computeExamAverage()


I tried making a for loop?

int total = 0;

           for(int i = 0; i < myExams.size(); i++)
                total = myExams.get(i);

But as you probably already know ArrayLists suck so it doesnt work.


so what i tried now was switching to for each loop still no good D:

int total = 0

for(APExam arg  : myExams)
                total += arg;


got it :D after messing with it for a while i found a .getScore method LOL

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.