ArithmeticException in Java — What It Means and How to Fix It

What Java's ArithmeticException means and how to fix it.

Published November 2, 2026

ArithmeticException is thrown for illegal arithmetic operations, most commonly integer division by zero.

Key points

  • Read the full stack trace from the top — it names the exact class, method, and line where the exception originated

Example

int x = 5 / 0;  // ArithmeticException: / by zero
More Java articles