diff --git a/core-java-modules/core-java-collections-list-6/src/main/java/com/baeldung/linkedlistremove/SinglyLinkedList.java b/core-java-modules/core-java-collections-list-6/src/main/java/com/baeldung/linkedlistremove/SinglyLinkedList.java index 58cf2ada6d..bb2dc05cf2 100644 --- a/core-java-modules/core-java-collections-list-6/src/main/java/com/baeldung/linkedlistremove/SinglyLinkedList.java +++ b/core-java-modules/core-java-collections-list-6/src/main/java/com/baeldung/linkedlistremove/SinglyLinkedList.java @@ -29,8 +29,9 @@ public class SinglyLinkedList { } public void remove(S element) { - if (isEmpty()) + if (isEmpty()) { return; + } Node previous = null; Node current = head; @@ -54,10 +55,9 @@ public class SinglyLinkedList { } public void removeLast() { - if (isEmpty()) + if (isEmpty()) { return; - - if (size() == 1) { + } else if (size() == 1) { tail = null; head = null; } else { @@ -73,8 +73,9 @@ public class SinglyLinkedList { } public boolean contains(S element) { - if (isEmpty()) + if (isEmpty()) { return false; + } Node current = head; while (current != null) {