int[2] we used for this array three number {2,3,4} but why we did not use for [3] this array four number ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

int[2] we used for this array three number {2,3,4} but why we did not use for [3] this array four number ?

30th Mar 2018, 1:51 PM
Nurullah Aydın
Nurullah Aydın - avatar
2 Answers
+ 1
array index starts from 0. so 0,1,2 are the indexes for the array. hence 3 index will result out of bound error
30th Mar 2018, 1:56 PM
kaliki chandu
kaliki chandu - avatar
0
thank both of you 🤙
30th Mar 2018, 1:59 PM
Nurullah Aydın
Nurullah Aydın - avatar