Code:
class Demo
{
static int m1()
{
try
{
System.out.println(" try block ");
int a = 10/0;
return 111;
}
// System.out.println(" hi ");
catch( Exception e )
{
System.out.println(" catch block ");
return 222;
}
finally
{
System.out.println(" final block ");
return 333;
}
//return 444;
}
public static void main( String args[] )
{
System.out.println(m1());
}
}
Output:
class Demo
{
static int m1()
{
try
{
System.out.println(" try block ");
int a = 10/0;
return 111;
}
// System.out.println(" hi ");
catch( Exception e )
{
System.out.println(" catch block ");
return 222;
}
finally
{
System.out.println(" final block ");
return 333;
}
//return 444;
}
public static void main( String args[] )
{
System.out.println(m1());
}
}
Output: