From 4f7df49fed8aabe4b808e8a2dc5efc4d998e8ccc Mon Sep 17 00:00:00 2001 From: Allan Rizza Date: Fri, 7 Apr 2023 14:32:33 -0300 Subject: [PATCH] using direct access in size of linked list --- LinkedList.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/LinkedList.java b/LinkedList.java index ca7f501..d5c8265 100644 --- a/LinkedList.java +++ b/LinkedList.java @@ -23,10 +23,6 @@ public static void main(String[] args) { System.out.println(ll.find(5)); } - public void setSize(int s) { - this.size = s; - } - public int getSize() { return this.size; } @@ -59,7 +55,7 @@ public boolean remove(int data) { prevNode.setNextNode(thisNode.getNextNode()); else this.root = null; - this.setSize(this.getSize()-1); + this.size--; return true; } prevNode = thisNode;