Queuequeue = new LinkedList<>(); queue.add("A"); queue.add("B"); queue.add("C"); System.out.println(queue); // [A, B, C]
QueueThe java.util Queue interface is part of the java.util package library.taskQueue = new LinkedList<>(); taskQueue.add(() -> System.out.println("Task 1")); taskQueue.add(() -> System.out.println("Task 2")); taskQueue.add(() -> System.out.println("Task 3")); while (!taskQueue.isEmpty()) { Runnable task = taskQueue.poll(); task.run(); }