Java:: IndexOutOfBoundException


#1

Given ArryaList A is size of 4
In the below line of code - A.get((A.size() - i) ==> when i=0 A.get((4)) which inturn leads to IndexOutOfBoundException. Last index of list is 3 but not 4

Answer for Java:: IndexOutOfBoundException

B.set(i + A.size(), A.get((A.size() - i) % A.size()));