previous | start | next

## Exceptions in the Contract

    /**

       . . .

       @throws IllegalArgumentException if queue is empty

    */

    public Message removeFirst()

    {

       if (count == 0)

          throw new IllegalArgumentException();

       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