next up previous contents
Next: Exceptions 2: Catch 1 Up: Java Notes Previous: Exceptions

Exceptions 1: Userdefined

/**
 *  This code is from the book:
 *  Winder, R and Roberts, G (1998)
 *  Developing Java Software
 *  John Wiley & Sons.
 *  It is copyright (c) 1997 Russel Winder
 *  and Graham Roberts.
 */

class l1Except1 extends Exception{//UserDefined
  public l1Except1(){
    super("A suitable message");
  }

  public l1Except1(String msg){
    super(msg);
  }
}
/******** sample compilation & run *******
# javac l1Except1.java
# java l1Except1      
In class l1Except1: void main(String argv[]) is not defined

# 
******************************************/

class UserException extends Exception
{
  public UserException()
  {
    super("A suitable message");
  }

  public UserException(String msg)
  {
    super(msg);
  }
}



Ananda Amatya
9/15/1999