I know that null is not a data type.
But null
can be only assigned for any type of Object
and String
.
Example:
Object o = null; // it tells that null is an object
String b = null; // it tells that null is of string type
Here null
can be assigned to both an Object
and a String
, but if I want to put assign any object into String we have to use type cast. but for null there is no type case.
something like the following
String b =(String) o;
Thats why I have doubt that which type of data type is null. How null can be assigned to any object or any String. How is null
implemented in Java?