Results 1 to 1 of 1
Thread: Example of ArithmeticException
- 01-22-2008, 08:28 PM #1
Example of ArithmeticException
You must have got across AirthmeticException while performing arithmetic operations. Review the code snippet below:
Java Code:public class CatchingArithmeticException { public static void main(String[] args) { int num=15; int den=0; //Integer Division try { System.out.println(num/den); } catch( ArithmeticException e) { System.out.println("Exception Occured : Denominator should not be 0 incase of integer division"); } //Modulo Division int firOp=20; int secOp=0; try { System.out.println(firOp%secOp); } catch( ArithmeticException e) { System.out.println("Exception Occured : Second operand should not be 0 incase of modulo division"); } } }
Similar Threads
-
Getting name of superclass (Example: ArithmeticException)
By Java Tip in forum Java TipReplies: 0Last Post: 11-12-2007, 11:53 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks