Skip to main content
added 27 characters in body
Source Link
Buhake Sindi
  • 89.5k
  • 30
  • 176
  • 234

Transfer of control in a finally block throws away any exception. The following code does not throw RuntimeException -- it is lost.

 public static void doSomething() { try { //Normally you would have code that doesn't explicitly appear //to throw exceptions so it would be harder to see the problem. throw new RuntimeException(); } finally { return; } } public static void doSomething() { try { //Normally you would have code that doesn't explicitly appear //to throw exceptions so it would be harder to see the problem. throw new RuntimeException(); } finally { return; } } 

From http://jamesjava.blogspot.com/2006/03/dont-return-in-finally-clause.html

Transfer of control in a finally block throws away any exception. The following code does not throw RuntimeException -- it is lost.

 public static void doSomething() { try { //Normally you would have code that doesn't explicitly appear //to throw exceptions so it would be harder to see the problem. throw new RuntimeException(); } finally { return; } } 

From http://jamesjava.blogspot.com/2006/03/dont-return-in-finally-clause.html

Transfer of control in a finally block throws away any exception. The following code does not throw RuntimeException -- it is lost.

public static void doSomething() { try { //Normally you would have code that doesn't explicitly appear //to throw exceptions so it would be harder to see the problem. throw new RuntimeException(); } finally { return; } } 

From http://jamesjava.blogspot.com/2006/03/dont-return-in-finally-clause.html

Post Made Community Wiki by CommunityBot
Source Link

Transfer of control in a finally block throws away any exception. The following code does not throw RuntimeException -- it is lost.

 public static void doSomething() { try { //Normally you would have code that doesn't explicitly appear //to throw exceptions so it would be harder to see the problem. throw new RuntimeException(); } finally { return; } } 

From http://jamesjava.blogspot.com/2006/03/dont-return-in-finally-clause.html