Usually one would come across “java.lang.ArithmeticException: / by zero” when tried to divide two numbers and the number in the denominator is zero.
Handling the ArithmeticException using try-catch block.
1. Firstly Surround the statements that could throw ArithmeticException with try-catch block.
2. Catch ArithmeticException
3. When any exception occurs, the execution falls onto the catch block from the point of occurrence of exception.
4. It executes the statement in catch block and continues with the statement present after the try-catch block.
5. So care has to be taken while handling the exceptions.