Apparently, null is not a constant
... Or at least that's what the compiler claims. Check out the following code for a simple annotation:
22 @Documented
23 @Inherited
24 @Target({ElementType.FIELD, ElementType.METHOD})
25 @Retention(RetentionPolicy.RUNTIME)
26 public @interface Sequence {
27 Class<? extends Collection> type() default null;
28 }
29
The compiler gives an error claming that the default cannot be 'null', as it must be a constant value.
Now, I ask you: What is null if not the mother of all constants?
Comments (3)
nullis a *type* as well as that type's singleton value.