Skip to content

Instantly share code, notes, and snippets.

@skyler
Created December 10, 2010 18:46
Show Gist options
  • Save skyler/736593 to your computer and use it in GitHub Desktop.
Save skyler/736593 to your computer and use it in GitHub Desktop.
try without catch--finally block will execute
public class T
{
public static void main(String[] args)
{
try {
dontCatchIt();
} catch (IOException ioe) {
System.out.println("Caught IOException: " + ioe.getMessage());
} catch (Exception e) {
System.out.println("Caught Exception: " + e.getMessage());
}
}
public static void dontCatchIt() throws Exception
{
try {
throwSomething();
} finally {
System.out.println("finally block ran!");
}
}
public static void throwSomething() throws IOException
{
throw new IOException("Test IOException");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment