Custom Search

Monday, 27 August 2012

Java Program to explain different methods of catch class


Java Program to explain different methods of catch class


Program
class catchMethod
{
public static void main(String args[])
{
int i,j,ans;
i=1;
j=0;
try
{
ans=i/j;
System.out.println("Ans is:"+ans);
}
catch(ArithmeticException e)
{
System.out.println("filIn: " + e.fillInStackTrace());
System.out.println("cause: " + e.getCause());
System.out.print("trace: "); 
e.printStackTrace();
System.out.println("messa: " + e.getMessage());
}

}
}


No comments:

Post a Comment

Laptops