We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 74cb5a5 commit ad02b19Copy full SHA for ad02b19
Collection/32_Queue.java
@@ -0,0 +1,31 @@
1
+import java.util.*;
2
+
3
+class QueueDemo {
4
5
+ public static void main(String[] args) {
6
7
+ Queue que = new LinkedList();
8
9
+ que.offer(10);
10
+ que.offer(20);
11
+ que.offer(50);
12
+ que.offer(30);
13
+ que.offer(40);
14
15
+ System.out.println(que);
16
17
+ // 1) peek();
18
+ System.out.println(que.peek());
19
20
+ // 2) element();
21
+ System.out.println(que.element()); // throws NoSuchElementException
22
23
+ // 3) poll();
24
+ que.poll();
25
26
27
+ // 4) remove()
28
+ que.remove();
29
+ System.out.println(que); // throws NoSuchElementException
30
+ }
31
+}
0 commit comments