- 1

JAVA shifting elements in an array

How do you shift elements of an array to the left? Eg [1,2,3,4]

14th Apr 2022, 5:30 PM
Ritika Chowdhury
2 odpowiedzi
+ 1
dont use java
16th Apr 2022, 5:27 PM
Spritzenkopf
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..
14th Apr 2022, 6:34 PM
Jayakrishna 🇮🇳