The throw Statement

The throw Statement

public Object pop() {
    Object obj;

    if (size == 0) {
        throw new EmptyStackException();
    }

    obj = objectAt(size - 1);
    setObjectAt(size - 1, null);
    size--;
    return obj;
}

All methods use the throw statement to throw an exception.

The throw statement requires a single argument: a throwable object. Throwable objects are instances of any subclass of the Throwable class.

The throw Statement — Structure map

Clickable & Draggable!

The throw Statement — Related pages: