What is null
?
Is null
an instance of anything?
What set does null
belong to?
How is it represented in the me
Bytecode representation
Java's null
has direct JVM support: three instructions are used to implement it:
aconst_null
: e.g. to set a variable to null
as in Object o = null;
ifnull
and ifnonnull
: e.g. to compare an object to null
as in if (o == null)
Chapter 6 "The Java Virtual Machine Instruction Set " then mentions the effects of null
on other instructions: it throws a NullPointerException
for many of them.
2.4. "Reference Types and Values" also mentions null
in generic terms:
A reference value may also be the special null reference, a reference to no object, which will be denoted here by null. The null reference initially has no run-time type, but may be cast to any type. The default value of a reference type is null.