java source code doubt

Posted by abson on Stack Overflow See other posts from Stack Overflow or by abson
Published on 2010-03-23T17:38:18Z Indexed on 2010/03/23 17:43 UTC
Read the original article Hit count: 323

Filed under:
|

this compiles

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

}

on the other hand this doesn't

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

why is it so?

© Stack Overflow or respective owner

Related posts about beginner

Related posts about java