They both mean the same thing. @Deprecated
is simply shorthand for @Deprecated()
. See §9.7.2. Marker Annotations of the Java Language Specification:
A marker annotation is a shorthand designed for use with marker annotation types (§9.6.1).
MarkerAnnotation:
@ TypeName
It is shorthand for the normal annotation:
@TypeName()
It is legal to use marker annotations for annotation types with elements, so long as all the elements have default values (§9.6.2).
Example 9.7.2-1. Marker Annotations
Here is an example using the Preliminary
marker annotation type from §9.6.1:
@Preliminary public class TimeTravel { ... }
As of Java 8 the @Deprecated
annotation had no elements, so it could only ever be a marker annotation. Since Java 9, however, it now has two elements: since
and forRemoval
. But since those elements have default values the annotation can still be used as a marker annotation.