-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.java
More file actions
36 lines (24 loc) · 860 Bytes
/
Copy pathApp.java
File metadata and controls
36 lines (24 loc) · 860 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
package tutorial61;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
public class App {
public static void main(String[] args) {
// (head) oooooooooooooooooooooooooooo <- (tail) FIFO first in first out
// note que has fixed size of 3 elements
Queue<Integer> ql = new ArrayBlockingQueue<Integer>(3);
ql.add(10);
ql.add(15);
ql.add(30);
try {
ql.add(40);
} catch (IllegalStateException e) {
System.out.println("Tried to add to many elements to array");
}
for(Integer value: ql){
System.out.println("que value: " + value);
}
Integer value;
System.out.println("removed an element: " + ql.remove());
// System.out.println("value is: " + value);
}
}