Skip to content

Instantly share code, notes, and snippets.

@xnorcode
Last active May 3, 2018 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xnorcode/d773bc6318d6a34673795f68926c46f8 to your computer and use it in GitHub Desktop.
Save xnorcode/d773bc6318d6a34673795f68926c46f8 to your computer and use it in GitHub Desktop.
Linked List Add Node To Head
public class LinkedList<T> {
// Reference to the head node
Node head;
public void addToHead(T data){
// create the new Node and add head as its next
Node newNode = new Node(data, head);
// replace head with the new node
head = newNode;
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment