In this tutorial, we will learn how to fix java.lang.ArithmeticException thrown when JRE finds an exceptional arithmetic operation like divide by zero.

What is java.lang.ArithmeticException?

java.lang.ArithmeticException occurs when java comes over an arithmetic operation that is exceptional. Usually, one would come across “java.lang.ArithmeticException: / by zero” which occurs when an attempt is made to divide two numbers and the number in the denominator is zero.

Let us see a sample program that could produce this exception.