-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueueTyp.java
More file actions
40 lines (40 loc) · 955 Bytes
/
Copy pathQueueTyp.java
File metadata and controls
40 lines (40 loc) · 955 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
36
37
38
39
40
package collectionPrgms;
import java.util.Queue;
import java.util.LinkedList;
import java.util.Deque;
import java.util.ArrayDeque;
public class QueueTyp {
public static void main(String[] args) {
Queue<Integer>q=new ArrayDeque<>();
Deque<Integer>q1=new LinkedList<>();
Deque<Integer>q2=new ArrayDeque<>();
Queue<Integer>q3=new LinkedList<>();
q.offer(5);
q.offer(1);
q.offer(3);
q.offer(4);
q.offer(2);
q.offer(0);
System.out.println(q);
/*q.offerFirst(9);
q.pollFirst();*/ //Only allowed for the dequeue interference
q1.offer(5);
q1.offer(1);
q1.offer(3);
q1.offer(4);
System.out.println(q1);
q2.offer(5);
q2.offer(1);
q2.offer(3);
q2.offer(4);
q2.pollFirst();
q2.offerFirst(2);
System.out.println(q2);
q3.offer(5);
q3.offer(1);
q3.offer(3);
q3.offer(4);
//q3.offerFirst(2); IT WILL NOT SUPPORT FOR THE QUEUE INTERFERENCE OF THE LINKEDLIST PARENT CLASS
System.out.println(q3);
}
}