-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
22 lines (18 loc) · 745 Bytes
/
Copy pathTest.java
File metadata and controls
22 lines (18 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.LinkedList;
import java.util.Queue;
public class Test {
private LinkedList schlange;
public Test() {
Queue<Bestellung> warteschlange = new LinkedList<Bestellung>();
Bestellung b1 = new Bestellung("Testbestellung");
Bestellung b2 = new Bestellung("Testbestellung2");
warteschlange.offer(b1);
warteschlange.offer(b2);
b1 = warteschlange.peek(); // Das wäre immer noch b1
// Die Warteschlange enthält weiterhin zwei Bestellungen
b1 = warteschlange.poll();
b2 = warteschlange.poll();
// Nun ist die Schlange wieder leer und wir haben unsere Bestellungen
Bestellung leer = warteschlange.peek(); // peek() gibt null zurück
}
}