Thursday, June 01, 2006

User defined Exceptions

Whenever you create your own exceptions, you follow some common steps.

Although you can certainly add your own methods and variables, it is more common to simply use the inherited methods defined in your superclasses. First, you want to define at least two constructors: a default, no-argument constructor, and a constructor that accepts a String object as a parameter. The latter constructor allows you to pass the message that you want this exception type to return from the getMessage() method. Normally, all these constructors do is invoke the superclass constructors, located in Exception.

1 Comments:

At 6:40 PM, Blogger Venky said...

is the getMessage(), a built-in method??

 

Post a Comment

<< Home