aspose file tools*
The moose likes Java in General and the fly likes ArrayIndex OutOfBoundsException? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "ArrayIndex OutOfBoundsException?" Watch "ArrayIndex OutOfBoundsException?" New topic
Author

ArrayIndex OutOfBoundsException?

Ellen Zhao
Ranch Hand

Joined: Sep 17, 2002
Posts: 581
Here is a class that solves linear equation system with LU-decomposition algorithmus. I got the error message when ran it:
Please enter an integer as the size of the matrix:
5
java.lang.ArrayIndex OutOfBoundsException: 5
at NB2A71.main(NB2A71.java:31)
Press any key to continue...
The source code is as following:

In this program, the initial values of a[i][j] and b[i] are specified here:

How should I modify the code so that it can run? Thank you very much in advance!
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Arrays start at zero, so that valid index range of your arrays will be 0 through 4. Modify the loop so that 5 cannot be a counter value.


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayIndex OutOfBoundsException?