Insert a Node at the Tail of a Linked List

  • + 1 comment

    first, check if the head is null (means that its start with emapty list) then the first if condition will handle that

    second, mantain head object by assigning its references to current then iterate over the current while current.next still containing Node, when it found current.next == null, means that current is the last Node, then it assign the new Node to Current.next and return the head

    with this way, we makesure that current would never be found as null