public class Node {
    Object cargo;
    Node next;

    // default constructor
    public Node () {
	cargo = null;
	next = null;
    }

    // other constructor
    public Node (Object cargo, Node next) {
	this.cargo = cargo;
	this.next = next;
    }

    public void print () {
	System.out.println (this);
    }

    public String toString () {
	return cargo + "";
    }

    public static void printBackward (Node list) {
        if (list == null) return;

        Node head = list;
        Node tail = list.next;

        printBackward (tail);
        System.out.print (head + ", ");
    }

    // copy: returns a copy of the given node and all that follow
    public static Node copy (Node list) {
	if (list == null) return null;
	return new Node (list.cargo, copy (list.next));
    }

    // findEnd: find and return the last node in the list, or null if
    // the list is empty
    public static Node findEnd (Node list) {
	Node node = list;
	while (node.next != null) {
	    node = node.next;
	}
	return node;
    }
}
