-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathDeque.java
More file actions
35 lines (35 loc) · 1.05 KB
/
Deque.java
File metadata and controls
35 lines (35 loc) · 1.05 KB
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
import java.util.ArrayDeque;
import java.util.Deque;
public class Dequeing
{
public static void main(String args[])
{
Deque<Integer> dq = new ArrayDeque<Integer>();
dq.add(7);
dq.add(6);
dq.add(3);
System.out.println("Inserted three elements are :");
for(Integer i : dq)
System.out.println(i);
dq.add(9);
System.out.println("add(9) : "+dq);
dq.addFirst(2);
System.out.println("addFirst(2) : "+dq);
dq.addLast(100);
System.out.println("addLast(100) : "+dq);
dq.push(5);
System.out.println("push(5) : "+dq);
dq.offer(4);
System.out.println("offer(4) : "+dq);
dq.offerFirst(1);
System.out.println("offerFirst(1) : "+dq);
dq.removeFirst();
System.out.println("removeFirst() : "+dq);
dq.removeLast();
System.out.println("removeLast() : "+dq);
dq.pop();
System.out.println("pop() : "+dq);
dq.remove(6);
System.out.println("remove(6) : "+dq);
}
}