forked from FatimaAlazazi/DataStructure2021
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShiftLeft.java
More file actions
35 lines (31 loc) · 825 Bytes
/
ShiftLeft.java
File metadata and controls
35 lines (31 loc) · 825 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
29
30
31
32
33
34
35
package Week2;
public class ShiftLeft {
static int [] a = {7,2,4,5,6,3,1};
static public void Print()
{
System.out.print("[ ");
for (int i = 0; i <a.length ; i++) {
if(i<a.length-1)
System.out.print(a[i]+" , ");
else
System.out.println(a[i]+" ]");
}
}
static public void ShiftLeft()
{
int i ;
for (i=0; i<a.length-1 ;i++)
{
a[i]=a[i+1];
}
a[a.length-1]=0;
}
public static void main(String[] args) {
System.out.println("Before Shift_Left : ");
Print();
System.out.println("=====================");
System.out.println("After Shift_Left : ");
ShiftLeft();
Print();
}
}