title: Beginner Java - inserting node into middle of a linkedlist - what does this do
body: <p>I'm learning about linked lists right now. I found an example for java that places a new node into the 3rd position on a linked list, but I've only ever seen insertion into a certain spot in the middle of a list like this done using 2 additional nodes, current and previous. I've also never seen anything like .getNext after another one like this. So can someone explain what each part of this snippet of code does and maybe rephrase it using nodes current and previous so I can understand how it relates and compares? Elem is the name given to the node being inserted and you don't have to instantiate current and previous if you do add an explanation involving those. I'll just assume it's already done.</p>
  
  <pre><code>elem.setNext(first.getNext().getNext());
  first.getNext().setNext(elem);
  numberOfElems++; 
  </code></pre>
  
  <p>Please let me know if you need more info to answer!</p>