|
|
Please see: http://www.cs.rit.edu/usr/local/jdk/docs/api/index.html
public class ErrorE {
private void thisMethodThrowsAnE(int index) throws Exception, Error {
if ( index == 0 ) {
System.out.println("thisMethodThrowsAnException() ---> " );
throw new Exception("in thisMethodThrowsAnException");
} else {
System.out.println("thisMethodThrowsAnError() ---> " );
throw new Error("in thisMethodThrowsAnException");
}
}
private void caller() {
for ( int index = 0; index < 2; index ++ ) {
try {
new ErrorE().thisMethodThrowsAnE(index);
} catch (Exception e) {
e.printStackTrace();
} catch (Error e) {
e.printStackTrace();
} finally {
System.out.println("Finally");
System.out.println("Ok, a few things to clean up" );
}
}
}
public static void main(String[] args) {
new ErrorE().caller();
}
}
Source Code: Src/7/ErrorE.java
java ErrorE
thisMethodThrowsAnException() --->
java.lang.Exception: in thisMethodThrowsAnException
at ErrorE.thisMethodThrowsAnE(ErrorE.java:7)
at ErrorE.caller(ErrorE.java:18)
at ErrorE.main(ErrorE.java:31)
Finally
Ok, a few things to clean up
thisMethodThrowsAnError() --->
java.lang.Error: in thisMethodThrowsAnException
at ErrorE.thisMethodThrowsAnE(ErrorE.java:10)
at ErrorE.caller(ErrorE.java:18)
at ErrorE.main(ErrorE.java:31)
Finally
Ok, a few things to clean up
|
|
Created by
unroff,
java2html &
& hp-tools.
© by csfac. All Rights Reserved (2010).
It is not allowed to print these pages on a CAST printer.
Last modified: 01/April/10 (17:16)