Please I have seen a lot of answers but I haven't seen the easiest solution to move around an array.
I want to continue moving to the next or previous element in the array (rows and column). Meaning if I reached the end of any rows or column, it takes me to the next or previous one, relative to the intialized size of the array.
Assuming I have a group of buttons to handle my directional events( left, right, up & down).
I have :
int twoD[][]= new int[3][3];
Output
0 1 2
3 4 5
6 7 8
I want to move right from
0,1,2,3,4,5,6,7,8 (Continuously)
I want to move left from
0,8,7,6,5,4,3,2,1 (Continuously)
I want to move up
0,8,5,2,7,4,1,6,3 (Continuously)
I want to move down
0,3,6,1,4,7,2,5,8,0 (Continuously)