# Thread: Array for counting from 1 to 100

1. Member
Join Date
Sep 2011
Posts
7
Rep Power
0

## Array for counting from 1 to 100

Here's the assignment:
Write methods for the following:
a)Find and return the total sum of numbers stored in an ArrayList.
b)find and return the maximum number from the ArrayList.
c)Find and return the minimum number from the ArrayList.
d)Find and return the mean of all the numbers from the ArrayList.
Write a tester class that creates an ArrayList of numbers. Add numbers from 1 to 100 to the ArrayList. Call all the utility methods from your utility class on the ArrayList that you have created. Print the results obtained.

I don't know how to get the ArrayList to count.

here's my thoughts, but I don't know how to get it to work, it's messing up.

ArrayList<Integer> numbers = new ArrayList<Integer>();
{
for(int i=0; i<numbers.size(); i++)
{
numbers [i]=i+1;
}

2. Senior Member
Join Date
Apr 2010
Location
Philippines
Posts
580
Rep Power
7

## Re: Array for counting from 1 to 100

try get() method of ArrayList.
SEE: ArrayList (Java Platform SE 6)
The Really Big Index

3. Member
Join Date
Sep 2011
Posts
7
Rep Power
0

## Re: Array for counting from 1 to 100

Like how would I do this in code though, I don't understand Arrays at all

4. ## Re: Array for counting from 1 to 100

Originally Posted by Magic8ballfollower
Like how would I do this in code though, I don't understand Arrays at all
We're not going to do your work for you. You've gotten a good suggestion and a link to the tutorials. I suggest you read and study the tutorial so you do understand ArrayLists, and then come back with your new code if you get stuck.

5. Member
Join Date
Sep 2011
Posts
7
Rep Power
0

## Re: Array for counting from 1 to 100

the "help" he gave is a link to a crappy site that isn't helping at all, and his reply didn't answer or corrrect anything I've already posted

6. ## Re: Array for counting from 1 to 100

Originally Posted by Magic8ballfollower
the "help" he gave is a link to a crappy site that isn't helping at all, and his reply didn't answer or corrrect anything I've already posted
That "crappy" site is where many of us, myself included, learned how to code in Java. The more you use the site, the less crappy and more useful it will become and the better coder you will be. Also, you really didn't ask any direct question in your first post. It isn't really our job to correct your code, but to try guide you so that you can learn about the concepts needed to correct it yourself. Otherwise we would be cheating you out of learning something well.
Last edited by Fubarable; 09-22-2011 at 05:09 AM.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•