Skip to content

Instantly share code, notes, and snippets.

Created January 15, 2013 07:09
Show Gist options
  • Save anonymous/4536816 to your computer and use it in GitHub Desktop.
Save anonymous/4536816 to your computer and use it in GitHub Desktop.
Simple question about java excepiton handling
/**
* What is printed to standard output ?
*/
void checkResult(String result) {
try {
String expected = null;
if(expected.equals(result)){
System.out.println( "Success" );
}
} catch( NullPointerException npex ) {
System.out.println( "NullPointerException thrown " );
} catch( Exception ex ) {
System.out.println( "Exception thrown " );
} finally {
System.out.println( "Done with exceptions " );
return;
}
System.out.println( "myMethod is done" );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment