-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStack.java
59 lines (51 loc) · 908 Bytes
/
Stack.java
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
public class Queue2
{
int []line = new int[10];
int left;
int right;
int elements;
Queue2()
{
elements=0;
right=0;
left=0;
}
public void insert(int val)
{
line[left]=val;
right++;
elements++;
}
public void delete()
{
right--;
elements--;
//System.out.println("Right: "+right+"\nLeft: "+left);
}
public void show()
{
System.out.println("Right: "+right+"\nLeft: "+left);
int x = elements;
System.out.println("No of Elements: "+elements);
while(x>-1)
{
System.out.println(line[x]);
x--;
}
}
public static void main (String[] args) throws java.lang.Exception
{
System.out.println("Queue using Array");
Queue2 q1=new Queue2();
q1.insert(5);
q1.insert(6);
q1.insert(7);
q1.show();
q1.delete();
q1.show();
}
}