Sunday, January 1, 2012

Demostrate the use of try..catch in Java

Example



import java.io.*;
public class A15
{
public static void main(String args[])

{

try
{
int a=Integer.parseInt(args[0]);
int b=Integer.parseInt(args[1]);
System.out.println("Subtraction of two number:"+(a-b));

}
catch(Exception e)
{
System.out.println("Enter number to Divide");
}
}
}

No comments:

Post a Comment