Wednesday, March 30, 2011

How to Handle ArithmeticException throw command Line Argument


class WithHandle{
public static void main(String args[])
{
System.out.println("started");
int n,d,q=1;
n=Integer.parseInt(args[0]);
d=Integer.parseInt(args[1]);
try{
q=n/d;
System.out.println("the result value is"+q);
}
catch(ArithmeticException e){
System.out.println("Divisible fails...2nd value shouldn't be 0");
}
}
}

No comments:

Post a Comment