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

Null References

In Java, it is possible for a reference type variable to refer to nothing at all. A reference that refers to nothing at all is called a null reference  . By default, an uninitialized reference is null.

We can explicitly assign the null reference to a variable like this:

f = null;
Also, we can test explicitly for the null reference like this
if (f == null)
    { /* ... */ }


next up previous contents index

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