Error java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 in my program android

后端 未结 2 1732
一个人的身影
一个人的身影 2021-01-12 07:22

I start to developpe in android, and I try to modify Snake code for including a call to browser for desplaying web page, when i execute my application it shows the page in t

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-12 07:37

    I think it's quite clear, here

    at com.example.android.snake.SnakeView.updateSnake(SnakeView.java:448)

    you are accessing an ArrayList that has been instantiated as new ArrayList(0), quite straightforward if you at least read the error.

    ArrayList objects are meant to automatically resize, but if you don't place anything in a zero-sized array list then you get this error.

提交回复
热议问题