Skip to content

Instantly share code, notes, and snippets.

Last active May 3, 2018 19:08
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