Skip to content

Instantly share code, notes, and snippets.

@xnorcode
Last active May 3, 2018 19:08
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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