leetcode/src/main/java/com/my/MyLinkedList.java
/** Add a node of value val before the first element of the linked list. After the insertion, the new node will be the first node of the linked list. */
Add a node of value val before the first element of the linked list. After the insertion, the new node will be the first node of the linked list.
Add a node of value val before the first element of the linked list . After the insertion the new node will be the first node of the linked list .
public void addAtHead(int val) {
        SingleNode node = new SingleNode(val);
        if(listIndex == 0){
            head = node;
            tail = node;
            listIndex ++;
        }else{
            listIndex ++;
            node.next = head;
            head = node;
        }
    }
public void addAtHead ( int val ) { SingleNode node = new SingleNode ( val ) ; if ( listIndex == 0 ) { head = node ; tail = node ; listIndex ++ ; } else { listIndex ++ ; node . next = head ; head = node ; } }
Add a node of value val before the first element of the linked list.
Add a node of value val before the first element of the linked list .