Skip to content

Commit a641789

Browse files
committed
style: include IT_NO_SUCH_ELEMENT
1 parent 2e387fe commit a641789

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

spotbugs-exclude.xml

-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@
7777
<Match>
7878
<Bug pattern="UWF_UNWRITTEN_FIELD" />
7979
</Match>
80-
<Match>
81-
<Bug pattern="IT_NO_SUCH_ELEMENT" />
82-
</Match>
8380
<Match>
8481
<Bug pattern="DLS_DEAD_LOCAL_STORE" />
8582
</Match>

src/main/java/com/thealgorithms/datastructures/queues/LinkedQueue.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,11 @@ public boolean hasNext() {
148148

149149
@Override
150150
public T next() {
151-
node = node.next;
152-
return node.data;
151+
if (hasNext()) {
152+
node = node.next;
153+
return node.data;
154+
}
155+
throw new NoSuchElementException();
153156
}
154157
};
155158
}

0 commit comments

Comments
 (0)