-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack_queue_inbuilt.java
38 lines (30 loc) · 1.05 KB
/
stack_queue_inbuilt.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
import java.util.*;
import java.util.Queue;
public class stack_queue_inbuilt {
public static void main(String[] args) {
Stack<Integer> stack = new Stack<>();
stack.push(34);
stack.push(45);
stack.push(2);
stack.push(9);
stack.push(18);
System.out.println(stack.pop());
System.out.println(stack.pop());
System.out.println(stack.pop());
System.out.println(stack.pop());
System.out.println(stack.pop());
System.out.println(stack.pop());
Queue<Integer> queue = new LinkedList<>();
queue.add(3);
queue.add(6);
queue.add(5);
queue.add(19);
queue.add(1);
System.out.println(queue.remove());
System.out.println(queue.remove());
Deque<Integer> deque = new ArrayDeque<>();
deque.add(89);
deque.addLast(78);
deque.removeFirst();
}
}