What is null in Java?

后端 未结 14 1394
陌清茗
陌清茗 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:24

    Null is not an instance of any class.

    However, you can assign null to variables of any (object or array) type:

     // this is false   
     boolean nope = (null instanceof String);
    
     // but you can still use it as a String
     String x = null;
     "abc".startsWith(null);
    

提交回复
热议问题