java - What is the class of null? -


this question has answer here:

in java when assign null object this:

private apple apple = null; 

is there class in java related null?

because in apache common-lang jar have defined null this:

public static class null implements serializable {             /**              * required serialization support. declare serialization compatibility commons lang 1.0            *             * @see java.io.serializable              */            private static final long serialversionuid = 7092611880189329093l;              /**             * restricted constructor - singleton.              */             null() {                super();             }             /**              * <p>ensure singleton.</p>             *             * @return singleton value              */             private object readresolve() {                 return objectutils.null;             }        } 

why have made this?

or bit pattern?

in java null not object , therefore not have class.

it have type though - see the language specification.

apache has created class called null (not null). entirely different thing. i'm guessing created represent null actual object - may make programming easier in ways.


Comments