class List {

    private Node head;

    public void putAtFront(int x) {
	Node newHead = new Node();
	newHead.data = x;
	newHead.next = head;
	head = newHead;
    }

    public String toString() {
	Node current = head;
	String result = "";
	while (current != null) {
	    result = result + " " + current.data;
	    current = current.next;
	}
	return result;
    }

    // return true if x is in the list, and false if not.
    public boolean search(int x) {
	Node current = head;
	while (current != null) {
	    if (current.data == x) {
		// we've found it!
		return true;
	    } else {
		current = current.next;
	    }
	}
	return false;
    }

}
