O'Reilly logo

Sun Certification Training Guide (310-025, 310-027): Java™ 2 Programmer and Developer Exams by Jamie Jaworski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Primitive Types and Literal Values

Java defines eight primitive types. Variables that are declared as primitive types are not references to objects. They are only placeholders to store primitive values. The eight primitive types are byte, short, int, long, float, double, char, and boolean. The byte, short, int, and long types represent 8-, 16-, 32-, and 64-bit signed integer values. The char type represents an unsigned 16-bit value. The float and double types represent 32-and 64-bit floating-point values. The ranges of the primitive types are shown in Table 2.1.

Table 2.1. Ranges of Numeric Types
TypeRange
booleantrue and false
byte-(27) to 27 - 1
char0 to 216 - 1
short-(215) to 215 - 1
int-(231) to 231 - 1
long-(263) to 263 - 1
float
 Float.MIN_VALUE ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required