Results 1 to 5 of 5
  1. #1
    UnTil_Fate is offline Member
    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    Default 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

  2. #2
    christopherx is offline Member
    Join Date
    Oct 2011
    Posts
    92
    Rep Power
    0

    Default 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.

  3. #3
    UnTil_Fate is offline Member
    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    Default 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 );

    }
    }

  4. #4
    serotonin is offline Member
    Join Date
    Jan 2013
    Location
    england
    Posts
    9
    Rep Power
    0

    Default 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]

  5. #5
    christopherx is offline Member
    Join Date
    Oct 2011
    Posts
    92
    Rep Power
    0

    Default Re: Help with Array List

    Quote Originally Posted by serotonin View Post
    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.

Similar Threads

  1. array List help please!
    By Dex in forum New To Java
    Replies: 7
    Last Post: 08-05-2012, 09:18 PM
  2. Array List
    By turtlish in forum New To Java
    Replies: 10
    Last Post: 12-20-2011, 09:48 PM
  3. Linked List, Array List time complexity
    By Rick99771977 in forum New To Java
    Replies: 4
    Last Post: 08-18-2011, 06:37 AM
  4. Replies: 2
    Last Post: 09-06-2010, 02:03 AM
  5. Array List
    By mashyum in forum Advanced Java
    Replies: 2
    Last Post: 07-28-2009, 07:47 AM

Tags for this Thread

Posting Permissions

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