|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Collection of frequently used language-related objects.
Field Summary | |
static Object |
NULL
An object representing the null object. |
static Object |
PURENULL
An object which behaves like NULL , but differs in the
equals method, which only returns true if the
object supplied is null . |
Field Detail |
public static final Object NULL
null
object.
This object can be used as either a replacement for null
or as a
flag for null
. For example, in an array searching algorithm, where
you are supplied with an object to search for (possibly null
), you
would probably need to write two algorithms, one using the equals
method, and one using the ==
comparator if the object supplied is
null
. With this object, however, you simply reassign the parameter
to this object, and you can then specify just one algorithm.
The other use, as a flag, can be used for situations where
null
is not allowed to be used, or if the use of
null
has a special meaning, and you wish to specify
null
outside the special meaning. You could also use
it to store information in an array, and use it to differentiate instances
of null
which were entered there, and instances of
null
which were placed there by the virtual machine when the
array was created.
The methods overridden from the Object
class are:
equals -
returns true
if the object to compare
it to, is null or itself.
hashCode -
returns 0
.
toString -
returns "null"
.
This object is serializable. If you want to use an object which acts in
the same way, but has an equals method which only returns
true
when the object supplied is null
, then
use PURENULL
.
PURENULL
public static final Object PURENULL
NULL
, but differs in the
equals
method, which only returns true
if the
object supplied is null
. If the object is supplied with
itself as an argument for the equals
method, it will return
false
.NULL
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |