Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

java.lang.IndexOutOfBoundsException: toIndex = 5

Options
  • 01-08-2007 2:00pm
    #1
    Registered Users Posts: 1,552 ✭✭✭


    java.lang.IndexOutOfBoundsException: toIndex = 5

    What usually causes this error?


Comments

  • Registered Users Posts: 500 ✭✭✭warrenaldo


    you have an array with 5 elements - you try to access the 6th element


  • Closed Accounts Posts: 161 ✭✭nude_hamster


    quinnd6 wrote:
    java.lang.IndexOutOfBoundsException: toIndex = 5

    What usually causes this error?

    an array with 5 elements , has indexes 0-4, an array with 4 elements has indexes 0-3 and so on.... An index of 5 would try to access the 6th element, which is out of bounds to the array.

    you probably have a for loop that doesnt have the correct guard or you are directly trying to access the 6th element of the array, when the array is simply smaller than 6 elements.


Advertisement