Cover Data Structures and Algorithms with Object-Oriented Design Patterns in Java
next up previous contents index

Primitive Types

The Java primitive types are boolean, char, short, int, long, float, and double. The Java language specification[16] defines the range of values provided by each primitive type and the set of operations supported by each type.

Every variable of a primitive type is a distinct instance of that type. Thus, an assignment statement such as

y = x;
takes the value of the variable x and copies that value into the variable y. After the assignment, x and y remain distinct instances that happen to have equal values.

A comparison of the the form

if (x == y)
    { /* ... */ }
tests whether the values contained in the variables x and y are equal.


next up previous contents index

Bruno Copyright © 1998 by Bruno R. Preiss, P.Eng. All rights reserved.