This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes ArrayIndexOutOfBoundException... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayIndexOutOfBoundException... " Watch "ArrayIndexOutOfBoundException... " New topic
Author

ArrayIndexOutOfBoundException...

Rashid Ali
Ranch Hand

Joined: Jan 16, 2001
Posts: 349
Dear folks
The following program works fine but when i try to calculate the average of the int arrays it gives the 'arrays out of bound exceptions'.
Could anybody helps me how to rectify this problem. Or suggest me how can i calculate the average of int arrays in the last of my output.
Thanks in advance.
Raghavendra Holla
Ranch Hand

Joined: Jun 02, 2000
Posts: 58
Simple..
problem is with your statement
average += randomNo[ i ] ;
is out side the loop and i at that time is 12 !!!.
Put it inside the loop.
Rashid Ali
Ranch Hand

Joined: Jan 16, 2001
Posts: 349
Great! thanks it's solved.
I was doing so with sum but not with average.
It's perfectly running now.
Thanks again.
Raashed
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ArrayIndexOutOfBoundException...