AP® Computer Science A glossary
ArithmeticException
Course: AP® Computer Science A Shows up in: Unit 1: Using Objects and Methods
The exception thrown when a program tries to divide an integer by the integer zero.
Appears in the course and exam description (CED): 1.3.C.6
Dividing an int by the int 0 compiles, because the compiler does not know the value will be 0, but it throws an ArithmeticException when it runs. Dividing by zero with a double is outside the course.
int count = 0;
System.out.println(12 / count);
Output:
Exception in thread "main" java.lang.ArithmeticException: / by zero Learn it properly, with a checkpoint 1.3 Expressions and Output