Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

While this statement is true, arithmetic operations in the Java platform require the same caution as in C and C++. Integer operations can result in overflow or underflow because Java does not provide any indication of these conditions and silently wraps (Java arithmetic throws an exception only on a division by zero exception).

Wiki Markup
The following excerpt is from the \[[JLS 03|AA. Java References#JLS 03]\] Integer (Overflow):

The built-in integer operators do not indicate overflow or underflow in any way. Integer operators can throw a NullPointerException if unboxing conversion of a null reference is required. Other than that, the only integer operators that can throw an exception are the integer divide operator / \ and the integer remainder operator \ %, which throw an ArithmeticException if the right-hand operand is zero, and the increment and decrement operators ++ and - which can throw an OutOfMemoryError if boxing conversion is required and there is not sufficient memory available to perform the conversion.

...