how to fix java.lang.IndexOutOfBoundsException

后端 未结 7 1355
长发绾君心
长发绾君心 2020-12-10 23:58

Exception in thread \"main\" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:604)

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-11 00:44

    You are trying to access the first element lstpp.get(0) of an empty array. Just add an element to your array and check for !lstpp.isEmpty() before accessing an element

提交回复
热议问题