Skip to Content
Java Projects - Second Edition
book

Java Projects - Second Edition

by Peter Verhas
August 2018
Intermediate to advanced
524 pages
14h 45m
English
Packt Publishing
Content preview from Java Projects - Second Edition

Queue

A Queue is a collection that usually stores elements for later use. You can put elements into a queue and you can pull them out. An implementation may specify the given order, that may be first in first out (FIFO) or last in first out (LIFO), or some priority-based ordering.

On a queue, you can invoke the add() method to add an element, remove() to remove the head element, and the element() method to access the head element without removing it from the queue. The add() method will throw an exception when there is a capacity problem and the element cannot be added to the queue. When the queue is empty, and there is no head element, the element() and remove() methods throw exceptions.

As exceptions can only be used in exceptional cases, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java 11 Cookbook - Second Edition

Java 11 Cookbook - Second Edition

Nick Samoylov, Mohamed Sanaulla

Publisher Resources

ISBN: 9781789131895Supplemental Content