package
com.David;
class MyException extends Exception{
private int detail;
MyException( int a){
this .detail = a;
}
public String toString(){
return " MyException[ " + this .detail + " ] " ;
}
}
public class MyTest {
static void compute( int a) throws MyException{
System.out.println( " Called compute( " + a + " ) " );
if (a > 10 ){
throw new MyException(a);
}
System.out.println( " Normal exit " );
}
public static void main(String[] args) {
try {
MyTest.compute( 1 );
MyTest.compute( 20 );
} catch (MyException e){
System.out.println(e);
}
}
}
class MyException extends Exception{
private int detail;
MyException( int a){
this .detail = a;
}
public String toString(){
return " MyException[ " + this .detail + " ] " ;
}
}
public class MyTest {
static void compute( int a) throws MyException{
System.out.println( " Called compute( " + a + " ) " );
if (a > 10 ){
throw new MyException(a);
}
System.out.println( " Normal exit " );
}
public static void main(String[] args) {
try {
MyTest.compute( 1 );
MyTest.compute( 20 );
} catch (MyException e){
System.out.println(e);
}
}
}