diff --git a/content/java/concepts/queue/terms/poll/poll.md b/content/java/concepts/queue/terms/poll/poll.md new file mode 100644 index 00000000000..d0e33b733d6 --- /dev/null +++ b/content/java/concepts/queue/terms/poll/poll.md @@ -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() \ No newline at end of file