Skip to content

Glossary: Data Structures and Algorithms in Java

NoSuchElementException

The error Java throws when you take from an empty collection with a method that insists on an item, such as `pop` on our `ArrayStack` or `removeFirst()` on a deque. `poll` returns `null` instead.

Where the book teaches it

Related terms

offer, poll, peeknull