public void appendToTail(int x){
        ListNode newNode = new ListNode(x);
        ListNode node = this;
        while(node.next!=null) {
            node = node.next;
        }
        node.next = newNode;
    }