program for 'try catch finally' in java programming
Java program using try catch finally block
public class Divide2
{
public static void main(String args[])
{
System.out.println("\nPROGRAM EXECUTION START HERE\n");
int NUM1,NUM2,RESULT;
try
{
NUM1=Integer.parseInt(args[0]);
NUM2=Integer.parseInt(args[1]);
RESULT=NUM1/NUM2;
System.out.println(NUM1+"/"+NUM2+"="+RESULT);
}
catch(Exception e)
{
System.out.println(e);
}
finally
{
System.out.println("\nTHE FINALLY BLOCK ALWAYS EXICUTED\n");
}
System.out.println("\nPROGRAM EXECUTION COMPLETE HERE\n");
}
}
observe the program and its output carefully
Comments
Post a Comment