import java.util.Scanner;
//=================================================================================================
public class UseLinkedListNode {
//-------------------------------------------------------------------------------------------------
    private static final Scanner keyboard = new Scanner(System.in);
    private static final String SENTINEL = "STOP";
//-------------------------------------------------------------------------------------------------
    public static void main(String[] args) {

        String userWord;
        LinkedListNode head;

        head = null;

        System.out.print("Enter a word : ");
        userWord = keyboard.nextLine();
        while (! userWord.equalsIgnoreCase(SENTINEL)) {
            head = new LinkedListNode(userWord,head);
            System.out.print("Enter a word : ");
            userWord = keyboard.nextLine();
        }

        System.out.print("Press return to continue ... ");
        keyboard.nextLine();
        printList(head);
    }
//-------------------------------------------------------------------------------------------------
    private static void printList(LinkedListNode node) {

        LinkedListNode nextNode;

        if (node == null) {
            System.out.println();
        } else {
            System.out.print(node + " ");
            nextNode = node.getNext();
            printList(nextNode);
        }
    }
//-------------------------------------------------------------------------------------------------
}
//=================================================================================================
