<<< Exception Handling Techniques | Index | >>> |
Exception class you define extends class Exception or one of its subclasses
Syntax to throw your own exception object:
throw new ExceptionClassName( messageString );
For example,
public class MyDivisionByZeroException extends Exception { public MyDivisionByZeroException() { super( "Cannot divide by zero" ); } public MyDivisionByZeroException( String strMessage ) { super( strMessage ); } }
<<< Exception Handling Techniques | Index | >>> |