When does the Garbage Collector pick up an object?
I'm learning about Data Structures and Algorithms and I've started to make a doubly linked list. Here is some code that is supposed to remove a datatype from a given index:
Code:
public T removeFrom(int index) {
DLNode<T> indexNode = this.find(index);
T element = indexNode.getElement();
indexNode.getNextNode().setPreviousNode(indexNode.getPreviousNode());
indexNode.getPreviousNode().setNextNode(indexNode.getNextNode());
return element;
}
How do I know when "indexNode" will be picked up by the garbage collector? Will it automatically be removed from memory after this code is run?