From 768e5f67ba87bf231f260e9682e7a52ff8a202a1 Mon Sep 17 00:00:00 2001 From: hertero Date: Tue, 30 Aug 2022 10:21:46 +0200 Subject: [PATCH] contains-Methode implementiert --- SimpleLinkedList/src/solution/SimpleLinkedList.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/SimpleLinkedList/src/solution/SimpleLinkedList.java b/SimpleLinkedList/src/solution/SimpleLinkedList.java index 892f356..7e1f069 100644 --- a/SimpleLinkedList/src/solution/SimpleLinkedList.java +++ b/SimpleLinkedList/src/solution/SimpleLinkedList.java @@ -62,18 +62,17 @@ public class SimpleLinkedList extends AbstractSimpleList { @Override public boolean contains(Object o) { - if(o == null) { + if (o == null) { return false; } - Node aktuellerKnoten = ersteKnoten; - while(aktuellerKnoten != null) { - aktuellerKnoten = aktuellerKnoten.getSuccessor(); + Node currentNode = firstNode; + while (currentNode != null) { + currentNode = currentNode.getSuccessor(); } - if(o.equals(aktuellerKnoten)) { + if (o.equals(currentNode)) { return true; } return false; - } @Override