What is null in Java?

后端 未结 14 1383
陌清茗
陌清茗 2020-11-21 20:49

What is null?

Is null an instance of anything?

What set does null belong to?

How is it represented in the me

14条回答
  •  一生所求
    2020-11-21 21:05

    Null in Java(tm)

    In C and C++, "NULL" is a constant defined in a header file, with a value like:

        0
    

    or:

        0L
    

    or:

        ((void*)0)
    

    depending on the compiler and memory model options. NULL is not, strictly speaking, part of C/C++ itself.

    In Java(tm), "null" is not a keyword, but a special literal of the null type. It can be cast to any reference type, but not to any primitive type such as int or boolean. The null literal doesn't necessarily have value zero. And it is impossible to cast to the null type or declare a variable of this type.

提交回复
热议问题