previous | start | next

## Exceptions in the Contract

    /**
       . . .
       @throws NoSuchElementException if queue is empty
    */
    public Message remove()
    {
       if (count == 0)
          throw new NoSuchElementException();
       Message r = elements[head];
       . . .
    }

- Exception throw part of the contract
- Caller can rely on behavior
- Exception throw not result of precondition violation
- This method has no precondition

previous | start | next