- 1
JAVA shifting elements in an array
How do you shift elements of an array to the left? Eg [1,2,3,4]
2 Answers
+ 1
dont use java
0
Store a[0] in temp variable.
a[i] = a[i+1] repeat this in a loop till array length-1
array[ length-1]= temp ; ie a[0]
Output : [2,3,4,1] hope it helps..