public class Test {
public static int test(int i) { try { if (i == 0) throw new Exception(); return 0; } catch (Exception e) { return 1; } finally { return 2; } } public static void main(String[] args) { System.out.println(test(0)); System.out.println(test(1)); } }
Output:
2
2
https://stackoverflow.com/questions/18205493/can-we-use-return-in-finally-block
No comments:
Post a Comment
I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.