In java when we assign null to any object like this:
private Apple apple = null;
Is there any class in java related to this null
?
Because in Apache common-lang jar they have defined null like this:
public static class Null implements Serializable {
/**
* Required for serialization support. Declare serialization compatibility with Commons Lang 1.0 * * @see java.io.Serializable
*/
private static final long serialVersionUID = 7092611880189329093L;
/**
* Restricted constructor - singleton.
*/
Null() {
super();
}
/**
* <p>Ensure singleton.</p>
*
* @return the singleton value
*/
private Object readResolve() {
return ObjectUtils.NULL;
}
}
Why they have made it like this?
or it is just a bit pattern?