public class Node {
    int cargo;
    Node next;

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

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

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

    // copy: return 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;
	if (node == null) return null;
	while (node.next != null) {
	    node = node.next;
	}
	return node;
    }
}
