Also available as ThrowUp.java

/**
 * Title: ThrowUp
 * Description: Silly example of throwing an exception in a catch
 * @author hollingd@cs.rpi.edu
 */


public class ThrowUp {

    public static void main(String[] args) {
        String tmp;
        try {
            // generate an ArrayIndexOutOfBoundsExceptions (on purpose!).
            for (int i=0;i<args.length+10;i++) {
                tmp = args[i];
            }
            System.out.println("I made it!");
        } catch (ArrayIndexOutOfBoundsException up) {
            throw new SecurityException("Trouble");
        }
    }
}