- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
Latest commit
28 lines (20 loc) · 455 Bytes
/
Copy pathTest.java
File metadata and controls
28 lines (20 loc) · 455 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
27
28
importjava.util.*;
publicclassTest
{
staticintarr[] = newint[]{1,2,3,4,5,6,7,8,9};
staticvoidrotate()
{
intx=arr[arr.length-1];
for (inti=arr.length-1;i>0;i--)
arr[i] = arr[i-1];
arr[0] = x;
}
publicstaticvoidmain(String[] args)
{
System.out.println("Given Array is:");
System.out.println(Arrays.toString(arr));
rotate();
System.out.println("Rotare Array is:");
System.out.println(Arrays.toString(arr));
}
}