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 :)

Recommended Answers

All 4 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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.