I have two instance variables, head and tail. In the code there's a line:
head = tail = new Node<E>();
Does this mean that there are two instances, head and tail, of class Node? I'm quite confused here.
It simply means:
tail = new Node<E>();
head = tail;
So there are 2 references (head
and tail
) pointing to the same Node<E>
instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With