java.lang.IndexOutOfBoundsException: Index code example
Example 1: java.lang.indexoutofboundsexception: index: 0, size: 0
The problem is that you are using set method to update element at index 0
set(index,value) method needs an element to present at that index
but you haven't added any element at that position in medium arraylist before that .
So you need to first add an element at index 0 thereafter only you can update it with set method
Example 2: indexoutofboundsexception java
IndexOutOfBoundsException is a subclass of RuntimeException mean it is an
unchecked exception which is usally thrown to indicate that an index of some
sort (such as to an array, to a string, or to a vector) is out of range.e.g
using List.
You can check it here:
https://stackoverflow.com/questions/40006317/what-is-indexoutofboundsexception-how-can-i-fix-it