Комментарии:
finally{
System.out.println("THANK YOU SIR")
}
Sir can u please explain the flow when return statement throws an exception ... i.e
import java.util.Scanner;
class Test
{
public static int m1()
{
try
{
System.out.print("try");
return 10/0;
}
catch (ArithmeticException e)
{
System.out.print("\ncatch");
return 88;
}
finally
{
System.out.print("\nfinally");
return 99;
}
//return 0;
}
public final strictfp synchronized static void main(String... vinay)
{
System.out.print(m1());
}
}
output :
try
catch
finally
99
it seems to be like only after execution of try blocks return statement finally block got executed.
if after executing finally block try blocks return statement executed then output will be as follows:
try
finally
catch
99
can u please elaborate this?
nice tutorial
ОтветитьThanku sir...
Ответить