Skip to content

Commit 5ab6a38

Browse files
committed
feat: Rotate array left by one position and print before and after
🧠 Logic: - Define an array of integers. - Print the original array using a helper method. - Rotate the array left by one: - Store the first element temporarily. - Shift all other elements one position to the left. - Place the first element at the end of the array. - Print the rotated array to observe the change. Signed-off-by: Somesh diwan <[email protected]>
1 parent c6280f3 commit 5ab6a38

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Section9ArrayAB/Array IMP/RotateArrayIMP.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ public static void main(String[] args) {
1010

1111
int temp = A[0];
1212

13-
for(int i=1; i<A.length; i++)
14-
{
13+
for(int i=1; i<A.length; i++) {
1514
A[i-1]=A[i];
1615
}
1716
A[A.length-1]=temp;
@@ -20,4 +19,4 @@ public static void main(String[] args) {
2019
System.out.print(x+",");
2120
System.out.println("");
2221
}
23-
}
22+
}

0 commit comments

Comments
 (0)