Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions content/java/concepts/queue/terms/poll/poll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# poll()

The `poll()` method is a member of the `Queue` interface in Java. It retrieves and removes the head (first element) of the queue. If the queue is empty, it returns `null` instead of throwing an exception. This makes it a safer alternative to the `remove()` method, which throws a `NoSuchElementException` if the queue is empty.

## Syntax

```java
E poll()