diff --git a/DataStructuresJava/src/LinkedList.java b/DataStructuresJava/src/LinkedList.java index 1c569a7..31d6e26 100644 --- a/DataStructuresJava/src/LinkedList.java +++ b/DataStructuresJava/src/LinkedList.java @@ -68,10 +68,10 @@ public void deleteAt(int index) { n = n.next; } - n1 = n.next; - n.next = n1.next; + + n.next = (n.next).next;//we dont want n1 this will automatically eligible for garbage collection //System.out.println("n1 " + n1.data); - n1 = null; + } }