The problem with your java.lang.ArrayIndexOutOfBoundsException: code java.lang.ArrayIndexOutOfBoundsException:
You loop to the 254th index , while the size of your array is 254 , which means that the index is 253 , since java starts it is indexed from 0.
The first loop should also run the same iterations as your second loop.
for (int i = 1; i < 254; i++) { /\ || || || This should not be 255 else you'll get OutOfBounds Exception. }
source share