posted 20 years ago
Hi there,
I have placed pretty the same two code.
What is the difference. If I un-comment "// throw new SimpleExceptio", I
have problem in compiling the code. Please can you explain, why do I have compilation problem ?
thanks
siva
[CODE:1] class SimpleException extends Exception {}
public class SimpleExceptionDemo {
public void f() throws SimpleException {
System.out.println( "Throwing SimpleException from f()");
throw new SimpleException ();
}
public static void main(String[] args) {
SimpleExceptionDemo sed = new SimpleExceptionDemo();
try {
// throw new SimpleException ();
if (sed != null ) {
throw new SimpleException (); }
System.err.println("Caught it-3!");
} catch(SimpleException e) {
System.err.println("Caught it-main()!");
}
}
} ///:~
[/CODE]
[CODE:2] class SimpleException extends Exception {}
public class SimpleExceptionDemo {
public void f() throws SimpleException {
System.out.println( "Throwing SimpleException from f()");
throw new SimpleException ();
}
public static void main(String[] args) {
SimpleExceptionDemo sed = new SimpleExceptionDemo();
try {
throw new SimpleException ();
if (sed != null ) {
throw new SimpleException (); }
System.err.println("Caught it-3!");
} catch(SimpleException e) {
System.err.println("Caught it-main()!");
}
}
} ///:~
[/CODE]
[ August 01, 2004: Message edited by: Siva kandasamy ]