| Author |
ArrayIndex OutOf Bounds Exception
|
mark watson
Ranch Hand
Joined: May 20, 2008
Posts: 44
|
|
Hi, I am getting ArrayIndexOutOfBoundException. Code that generating this exception is it is showing that exception is at last line of the code block. I am facing difficulty to find out the cause of exception. Please help me regarding this. Thanks in advacne -mark
|
 |
arunkumar subramanian
Ranch Hand
Joined: Jun 10, 2008
Posts: 32
|
|
Hi Mark I think your FOR loop hits the end of Array Try for(int i=0;i < al1.length;i++){ Hope this helps
|
 |
Robin Lane
Ranch Hand
Joined: Apr 30, 2008
Posts: 76
|
|
Originally posted by arunkumar subramanian: Hi Mark I think your FOR loop hits the end of Array
He's right, Mark. Remember, array indices start at zero. So, the length of your array is 14 but has index numbers of 0 - 13. Therefore, your counter (i, in your code) must be less than, not equal to or less than, the array length.
|
Disclaimer: The author of this post makes no claims, implied or otherwise, as to her ability to understand anything but the simplest of answers. Further, the author of this post has no programming background whatsoever and has taken one Java Programming class which was 9 weeks long. She does want to learn, so please teach patiently.
|
 |
 |
|
|
subject: ArrayIndex OutOf Bounds Exception
|
|
|