Головна‎ > ‎Java‎ > ‎Додатково‎ > ‎

Черга

Queue<String> queue = new LinkedList<>();
queue.offer("Lviv");
queue.offer("Kyiv");
queue.offer("Odesa");
queue.offer("Dnipro");

System.out.println(queue.peek());
System.out.println(queue.size());

String town;
while ((town = queue.poll()) != null) {
     System.out.println(town);
}
System.out.println(queue.size());