Fatal Exception: java.lang.IndexOutOfBoundsException: Index: 4, Size: 1 at java.util.ArrayList.get(ArrayList.java:437) what does this mean, any fix for above issue.
Any help is appreciate!
CodePudding user response:
hello @viji this means that you're trying to access the index 4
of an array or a list that only has 1
element inside, so before accessing an item inside an array or a list please check first if the index isn't greater than the array size
with something like this
if( list.size() > index) {
list.get(index)
}
or you can use a try catch block but that's not really solving the problem
you may follow this link to know more about the issue
CodePudding user response:
You have to check your arraylist size first and check your data into console log it look you'r adding more data ( arrraylist.size< your data)