Check out example codes for "shift elements in array java". It will help you in understanding the concepts better.

Code Example 1

// Shift right from index of 'a' to 'b'
for(int i = b; i>a; i--) { array[i] = array[i-1]; }
/* Note: element at 'a' index will remain unchanged */

// Shift left from index of 'b' to 'a' 
for(int i = a; i<b; i++) { array[i] = array[i+1]; }
/* Note: element at 'b' index will remain unchanged */

Learn ReactJs, React Native from akashmittal.com