Results 1 to 3 of 3
  1. #1
    javagirl is offline Member
    Join Date
    Feb 2014
    Posts
    6
    Rep Power
    0

    Default 2 Dimensional Array

    I am trying to test on a small scale an error message that I am getting within my 2-D Array. On a subset scale it is a 46X1; however, on a larger scale it is a 46x9. Of the 46 elements, only 10 have values so I only want to test the values where the value is greater than 0. I have attached a code snippet below. Any assistance that you can provide will be greatly appreciated :-)


    for(int x=0; x<LNValues.length; x++){

    for(int y=0; y<2; y++){
    double d = Math.log(eValues[x][y] - kValue);

    if(d > 0){
    LNValues[x][y] = roundThreeDecimals(d);

    }
    else{
    LNValues[x][y] = 0;

    }
    }
    }

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    3,383
    Rep Power
    5

    Default Re: 2 Dimensional Array

    If you are using a 46 x 1 array then the problem is with your inner for loop. You are indexing from 0 to 1 inclusive. Best to do it like this:
    Java Code:
    for (int y = 0; y < LNValues[x].length; y++) {
    //stuff here
    }
    And in the future please place your code between [code][/code] tags to format it.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    javagirl is offline Member
    Join Date
    Feb 2014
    Posts
    6
    Rep Power
    0

Similar Threads

  1. two dimensional array
    By grace425 in forum New To Java
    Replies: 2
    Last Post: 02-23-2013, 12:01 AM
  2. two dimensional array
    By shahnawazzzzzz in forum Java Software
    Replies: 2
    Last Post: 10-05-2011, 04:47 AM
  3. 2 dimensional array
    By sehudson in forum New To Java
    Replies: 5
    Last Post: 02-20-2011, 11:56 PM
  4. 2 dimensional array help!
    By ber1023 in forum New To Java
    Replies: 9
    Last Post: 01-02-2011, 12:29 AM
  5. Two dimensional array
    By niu_niu in forum New To Java
    Replies: 4
    Last Post: 06-13-2010, 12:34 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
  •