Created
February 22, 2011 10:28
-
-
Save mackato/838477 to your computer and use it in GitHub Desktop.
This file contains 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
class TestFinally { | |
int num; | |
public static void main(String[] args) { | |
TestFinally test = new TestFinally(); | |
int ret = test.increment(); | |
assert ret == 1; | |
assert test.num == 2; | |
System.out.println("Done."); | |
} | |
public TestFinally() { | |
num = 0; | |
} | |
public int increment() { | |
int ret = 0; | |
try { | |
throw new RuntimeException("Error"); | |
} catch (RuntimeException e) { | |
num++; ret++; | |
return ret; | |
} finally { | |
num++; ret++; | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment