From aceb7ce210f0cf3e8b9a93658f8d9bcbae09d6bf Mon Sep 17 00:00:00 2001 From: Mohammad Abdullah Date: Tue, 29 Jul 2025 06:34:16 -0400 Subject: [PATCH] Add Java Queue term: poll() method (#7365) --- content/java/concepts/queue/terms/poll/poll.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 content/java/concepts/queue/terms/poll/poll.md 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