Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

java.lang.IndexOutOfBoundsException: toIndex = 5

  • 01-08-2007 02:00PM
    #1
    Registered Users, Registered Users 2 Posts: 1,559 ✭✭✭


    java.lang.IndexOutOfBoundsException: toIndex = 5

    What usually causes this error?


Comments

  • Registered Users, Registered Users 2 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