Java code is wrong


#1

Given A : [5, 10, 2, 1]
when i=0
B.set(i + A.size(), A.get((A.size() - i) % A.size()));

   A.size()-i = 4-0 = 4
   A.get(4) leads to IndexOutOfBoundException

#2

For i == 0

((A.size() - i) % A.size()) ==> ((4 - 0) % 4) ==> ( 4 % 4 ) ==> 0

Hence we get

A.get(0) 

And not

A.get(4)

#3

This code is correct