finally and return

Posted by abson on Stack Overflow See other posts from Stack Overflow or by abson
Published on 2010-05-13T06:16:05Z Indexed on 2010/05/13 6:24 UTC
Read the original article Hit count: 281

Filed under:
|
In the below example,

class ex8
{
public void show()
{
try
{   int a=10/0; return;}
catch(ArithmeticException e)
{   System.out.println(e);  return ;}
finally
{   System.out.println("Finally");  }

}

public static void main(String[] args)
{
new ex8().show();
}
}

the output is:

java.lang.ArithmeticException: / by zero
Finally

How is it that Finally gets printed in spite of return statement in catch?

© Stack Overflow or respective owner

Related posts about java

Related posts about beginner