I know that null is not a data type.
But null
can be only assigned for any type of Object
and String
.
Example:
The null
reference and keyword are Java built-in constructs and are treated specially by the compiler. The compiler then emits the corresponding bytecode instructions depending on the context which null
is used in.
Note that this behavior is different from older languages such as C or C++03 where NULL pointer was simply a zero constant.