Here's a demo to create a custom exception class.
GeSHi (java):
/*--------------------------------------------------------------------------
// Author List:
// deAppel <Creator>
//
// Description:
// Create a custom exception class. Part 1/2
//
// Environment:
// This software was developed using Eclipse and Java 1.6
//
// Copyright Information:
// Copyright (C) 2007 <Institution><None>
// Ark de Appel www.engineeringserver.com
//
//----------------------------------------------------------------------*/
public class ExceptionDemo{
public static void main
(String[] args
){ ExceptionDemo ED = new ExceptionDemo();
ED.oopsExcepton(12);
}
public void oopsExcepton(int i){
if (i < 18){
try {
throw new ExceptionDemoClass("Age below 18");
} catch (ExceptionDemoClass e) {
e.printStackTrace();
}
}
if (i > 18){
System.
out.
println("Age 18+");
}
}
}
Created by GeSHI 1.0.7.20
GeSHi (java):
/*--------------------------------------------------------------------------
// Author List:
// deAppel <Creator>
//
// Description:
// Create a custom exception class. Part 2/2
//
// Environment:
// This software was developed using Eclipse and Java 1.6
//
// Copyright Information:
// Copyright (C) 2007 <Institution><None>
// Ark de Appel www.engineeringserver.com
//
//----------------------------------------------------------------------*/
public class ExceptionDemoClass
extends Exception{
public ExceptionDemoClass(){
}
public ExceptionDemoClass
(String msg
){ super(msg);
}
}
Created by GeSHI 1.0.7.20