Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArrayIndexOutOfBoundException...

 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great! thanks it's solved.
I was doing so with sum but not with average.
It's perfectly running now.
Thanks again.
Raashed
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic