java.lang.IndexOutOfBoundsException: Index: 1365, Size: 1365
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.Engine.write(Engine.java:114)
at com.Engine.read(Engine.java:90)
at com.Engine.main(Engine.java:19)
I understand that my array is out of bounds, but what does the
Index: 1365, Size: 1365
indicate?
And how could I go by fixing this? Just increase the size of my array?
-Size is the size of the array(Amount of elements that can hold).
-Index is the location that you were trying to access.
NOTE 1: Since the first index is 0, you where trying to access 1+ the maximim of the array so that is why you got that exception
FIX OPTION 1
To fix this exception in the case you are using a loop to manipulate the elements you could do something like this:
FIX OPTION 2
As you said increasing the size would be another option. You just need to do something like this:
BUT
That would be not very flexible, in case you want to increase it again in the future. So another option to avoid something like this would be to use a bit more advanced data structure or collection, like a List, because they automatically get increase when in needed.
See more information about data structures here: http://tutorials.jenkov.com/java-collections/index.html
Example 1 creation:
Example 2 iteration: