Java by API/java.lang/Exception
Версия от 17:43, 31 мая 2010; (обсуждение)
Subclass Exception
/*
* 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);
}
}
}