JAVA shifting elements in an array | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
- 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 Antworten
+ 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 🇮🇳