Java by API/java.lang/Exception
Subclass Exception
<source lang="java">
/*
* Output: * * caught MyException[10] * */
class MyException extends Exception {
private int detail; MyException(int a) { detail = a; } public String toString() { return "MyException[" + detail + "]"; }
} public class MainClass {
public static void main(String args[]) throws Exception { try { throw new MyException(10); } catch (MyException e) { System.out.println("caught " + e); } }
}
</source>