index out of range exception occurred [duplicate]

Indexes in arrays start with 0. So array with 1000 elements will have indexes from 0 to 999. It throws at the 1000th index. As a solution, you can change your loop to have following condition: i < 1000 instead.

Leave a Comment