Java Reference
In-Depth Information
Table 2-1 Java's Built-in Primitive Data Types
Java strictly specifies a range and behavior for each primitive type, which all implement-
ations of the Java Virtual Machine must support. Because of Java's portability requirement,
Java is uncompromising on this account. For example, an int is the same in all execution
environments. This allows programs to be fully portable. There is no need to rewrite code
to fit a specific platform. Although strictly specifying the range of the primitive types may
cause a small loss of performance in some environments, it is necessary in order to achieve
portability.
Integers
Java defines four integer types: byte , short , int , and long , which are shown here:
As the table shows, all of the integer types are signed positive and negative values. Java
does not support unsigned (positive-only) integers. Many other computer languages sup-
port both signed and unsigned integers. However, Java's designers felt that unsigned in-
tegers were unnecessary.
 
Search WWH ::




Custom Search