next up previous
Next: 1.3.1.0.1 Numeric Constants Up: 1.3 Java Data Types Previous: 1.3 Java Data Types

1.3.1 Primitive Types

All primitive values belong to one of eight primitive types: int, float, boolean, char, byte, short, long, and double. Four of these types designate different sizes of bounded integers: In practice, only three of these primitive types are widely used: int, boolean, and double.

A program should never contain explicit references to any of the specific integer constants given above. They can always be replaced by references to the static fields MIN_VALUE and MAX_VALUE in the corresponding ``container'' class: Byte, Short, Integer or Long. Java has a built-in container class for each primitive type. For example, in the container class Integer corresponding to the primitive type int, MIN_VALUE = -2147483648 and MAX_VALUE = 2147483647. For more information on the primitive container classes, read the on-line documentation from Sun Microsystems for the built-in class Number and its subclasses.

The boolean type has two values true and false. The char type supports the Unicode character set which includes all conventional ASCII characters plus almost any foreign character imaginable. The char type is rarely used in Java programs because a flexible String object type is built-in to the language. The remaining two types float and double are used for approximate computations involving real numbers; they denote standard IEEE 32-bit and 64-bit formats, respectively.



 
next up previous
Next: 1.3.1.0.1 Numeric Constants Up: 1.3 Java Data Types Previous: 1.3 Java Data Types
Corky Cartwright
2000-01-07