- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
Latest commit
26 lines (21 loc) · 602 Bytes
/
Copy pathTest.java
File metadata and controls
26 lines (21 loc) · 602 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
importjava.util.Arrays;
publicclassTest {
staticintarr[] = newint[] { 1, 2, 3, 4, 5 };
staticvoidrotate() {
inti = 0, j = arr.length - 1;
while (i != j) {
inttemp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
i++;
}
}
/* Driver program */
publicstaticvoidmain(String[] args) {
System.out.println("Given Array is");
System.out.println(Arrays.toString(arr));
rotate();
System.out.println("Rotated Array is");
System.out.println(Arrays.toString(arr));
}
}