From f5c7f8629893376c13c0f60151279bd15bc792f6 Mon Sep 17 00:00:00 2001 From: vil02 Date: Sun, 2 Jun 2024 22:14:18 +0200 Subject: [PATCH] style: include `IT_NO_SUCH_ELEMENT` --- spotbugs-exclude.xml | 3 --- .../thealgorithms/datastructures/queues/LinkedQueue.java | 7 +++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml index 711b34b0cc6f..ae10d1045dfe 100644 --- a/spotbugs-exclude.xml +++ b/spotbugs-exclude.xml @@ -77,9 +77,6 @@ - - - diff --git a/src/main/java/com/thealgorithms/datastructures/queues/LinkedQueue.java b/src/main/java/com/thealgorithms/datastructures/queues/LinkedQueue.java index 8a788317c372..171f24e09396 100644 --- a/src/main/java/com/thealgorithms/datastructures/queues/LinkedQueue.java +++ b/src/main/java/com/thealgorithms/datastructures/queues/LinkedQueue.java @@ -148,8 +148,11 @@ public boolean hasNext() { @Override public T next() { - node = node.next; - return node.data; + if (hasNext()) { + node = node.next; + return node.data; + } + throw new NoSuchElementException(); } }; }