Print the Elements of a Linked List

  • + 1 comment

    Similar solution. You don't need the if statement for this problem though.

    if(head == null){
          System.out.print("");
          }
        
        else{
        Node current = head; 
        while(current != null){
            System.out.println(current.data);
            current = current.next;}
       }