Created
December 10, 2010 18:46
-
-
Save skyler/736593 to your computer and use it in GitHub Desktop.
try without catch--finally block will execute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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