Page 2 of 2 FirstFirst 12
Results 21 to 23 of 23
  1. #21
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default Re: Make the sum of all elements of only one dimension of an array

    java.lang.ArrayIndexOutOfBoundsException: 4
    One of the indexes you are using is past the end of the array. If you don't know which one, print out all their values so you can see which one it is.
    Remember that array indexes start at 0 and go to the array length -1.

  2. #22
    ana_carol is offline Member
    Join Date
    Dec 2011
    Posts
    11
    Rep Power
    0

    Default Re: Make the sum of all elements of only one dimension of an array

    I don't understand.

  3. #23
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default Re: Make the sum of all elements of only one dimension of an array

    I don't understand.
    Please explain what part of what I said you do not understand.
    Here is a sample of how to get this error: ArrayIndexOutOfBoundsException: 4
    int[] anArray = new int[4];
    System.out.println(anArray[4]);


    Add a println in the sum method that prints out the values of all the variables passed to the method.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Single to multi-dimension array
    By Migy in forum New To Java
    Replies: 2
    Last Post: 04-05-2011, 06:12 PM
  2. Replies: 5
    Last Post: 04-15-2010, 05:55 PM
  3. Replies: 5
    Last Post: 05-18-2009, 12:42 PM
  4. noob: two-dimension array
    By bobmasta5 in forum New To Java
    Replies: 5
    Last Post: 03-15-2009, 11:42 PM
  5. Arraylist to a 2- dimension array conversion
    By mars123 in forum New To Java
    Replies: 1
    Last Post: 12-06-2007, 11:24 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
  •