24
Throwing Exceptions
•The MessageString argument contains a custom error message that can be retrieved from the exception object’s getMessage method.
•If you do not pass a message to the constructor, the exception will have a null message.
–throw new Exception("Out of fuel");
–Note: Don’t confuse the throw statement with the throws clause.
•Text example: DateComponentExceptionDemo.java