The Department of Computer Science & Engineering
|
|
STUART C. SHAPIRO: CSE
115 C
|
Values of Java primitive types are not objects, but for each
primitive type there is a wrapper (or "boxed") class that is a
subclass of java.lang.Object.
The primitive types we will discuss, and their corresponding wrapper classes are:
| Primitive | Wrapper |
|---|---|
int | java.lang.Integer |
boolean | java.lang.Boolean |
double | java.lang.Double |
int, and its wrapper class is java.lang.Integer.| Operator | Meaning |
|---|---|
+ | addition or unary plus |
- | subtraction or unary minus |
* | multiplication |
/ | integer division |
% | modulus (remainder) |
Their precedence order is:
| unary +, unary - |
| *, /, % |
| +, - |
Shortcuts, e.g. += and ++
Autoboxing makes the difference between ints and Integers almost invisible.
See java.lang.Math for some functions provided by the Java library.