@deprecated vs @Deprecated

@Deprecated is an annotation that is read by the compiler, used to mark a method as deprecated to the compiler and will generate a deprecation compile-time warning if the method is used.

@deprecated is a javadoc tag used to provide documentation about the deprecation. You can use it to explain why the method was deprecated and to suggest an alternative. It only makes sense to use this tag in conjunction to the @Deprecated annotation.

Example usage:

/**
 * This method does ...
 * @deprecated As of <product> <version>, because ... use
 *             {@link #replacementMethod()} instead.
 */
@Deprecated
public void deprecatedMethod() {
    // ...
}

Here is a guide on deprecation, check it out for more information.


To answer your question more specifically, you should either use @Deprecated or both. The @Deprecated annotation marks your method as deprecated to any tool that cares about it, as it is available during both run-time and compile-time. The javadoc tool takes notice of @Deprecated and documents the deprecation even if you didn't use the @deprecated tag.

If we document a method as deprecated by using the javadoc tag, but without annotating it with the annotation, then the information about the deprecation will not be available in the compiled class files.


@deprecated Javadoc Tag: You can use the @deprecated tag to make Javadoc show a program element as deprecated. The @deprecated tag must be followed by a space or newline.

@Deprecated Using the @Deprecated annotation to deprecate a class, method, or field ensures that all compilers will issue warnings when code uses that program element. In contrast, there is no guarantee that all compilers will always issue warnings based on the @deprecated Javadoc tag

refer here