Some work must be handled in arrival order, like level-by-level BFS, while other work needs last-in first-out, like matching brackets. A Queue gives FIFO, and an ArrayDeque can act as both a queue and a stack. Prefer ArrayDeque over the old Stack class, which is synchronized and slower. If items should come out by priority instead of arrival time, use a PriorityQueue.