what happens when your program attempts to access an array element with an invalid index? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what happens when your program attempts to access an array element with an invalid index?

17th Oct 2019, 9:59 AM
Ham Zah
Ham Zah - avatar
3 Answers
+ 10
A run time exception (ArrayOutOfBoundsException) will occur when any Java program will try to access an invalid index of an array i.e negative index or index higher than the size of the array. Example : https://code.sololearn.com/cTL559W6UgmV/?ref=app
17th Oct 2019, 10:05 AM
Nova
Nova - avatar
+ 8
Each dimension in an array has an upper and lower bound, which determine the range of values that can be used as subscripts for that dimension. Lower bound will be the minimum index value while the upper bound will be the maximum index value.
18th Oct 2019, 2:54 PM
Nova
Nova - avatar
+ 1
What means by bound in java?
18th Oct 2019, 10:58 AM
Ham Zah
Ham Zah - avatar