+ 1

why is it x<myArr.length but not x==?

3rd May 2017, 6:18 AM
m y
m y - avatar
2 Answers
+ 28
For an array of size 5, the valid indices are: 0,1,2,3,4. So index 5 will be out of range, that's why the length is always excluded from index.
3rd May 2017, 7:10 AM
Shamima Yasmin
Shamima Yasmin - avatar
+ 1
because array index starts from 0.
3rd May 2017, 9:07 AM
shobhit
shobhit - avatar