View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide

Java and Math Basics

This includes the primitive types (for the AP exam you just need to know int, double, boolean) and arithmatic expressions. Be sure to cover the remainder operator '%' (also called the modulus operator). Remind students that integer expessions have integer results (throws away any fractional part). Expression with a double in them will give a double result. Also cover Integer.MAX_VALUE and Integer.MIN_VALUE and the fact that they wrap around when you add one or subtract one. Also cover casting to change the type of a value or variable.

Have your students predict what these will do and then try them in DrJava's interaction pane:

1 / 3
1.0 / 3
1 / 3.0
(double) (1 / 3)
((double) 1) / 3
1 % 3
4 % 3
2 % 3
Integer.MAX_VALUE + 1
Integer.MIN_VALUE - 1

Review the primitive types on the exam: int, double, and boolean at
Review the operator precedence table at
Do the Java Arithmatic Expression Problets at

Link to this Page