# Help with Array List

• 01-24-2013, 02:47 AM
UnTil_Fate
Help with Array List
I'm a newbie in Java and am currently learning Array List. If any of you will be so kind,I need to complete these basic exercises with for loops but I'm not sure how to set it up.
Programming Exercises for Chapter 46
• 01-24-2013, 03:13 AM
christopherx
Re: Help with Array List
First things first. We aren't going to do your work for you. List out the exercises that you want help with, and we'll give you guidance.
• 01-25-2013, 12:24 AM
UnTil_Fate
Re: Help with Array List
I understand.
Then for the 1st exercise, this is what i got as of now, unsure of what to add in the for loop.

class Exercise1
{
public static void main ( String[] args )
{
int[] val = {0, 1, 2, 3};

for(int i;i<=3;i++)
{
val
}
sum = val

System.out.println( "Sum of all numbers = " + sum );

}
}
• 01-25-2013, 10:35 PM
serotonin
Re: Help with Array List
in your program code there are several things to look at..
you need to give the variable i an initial value
you need to declare what type of variable sum is and give it an initial value
the expression(formula) within your for loop for the running total i.e. sum = sum + val[i]
• 01-26-2013, 04:30 PM
christopherx
Re: Help with Array List
Quote:

Originally Posted by serotonin
in your program code there are several things to look at..
you need to give the variable i an initial value
you need to declare what type of variable sum is and give it an initial value
the expression(formula) within your for loop for the running total i.e. sum = sum + val[i]

We don't tell people how to do their homework. We give them guidance, links, lessons etc.