Which annotation marks a method as deprecated?

The story behind the answer

The @Deprecated annotation marks a Java method as deprecated. It tells developers that the method is obsolete, discouraged for new code, or likely to be replaced, changed incompatibly, or removed in a future release.

When a method is annotated, Java compilers can issue a deprecation warning when code uses it. The annotation belongs to the java.lang package, so no import is needed. For example, a declaration can begin with @Deprecated before the method signature. Modern Java versions also allow optional metadata such as since, which records the release where deprecation began, and forRemoval, which signals a stronger possibility of future removal.

Java also has a related Javadoc tag, @deprecated, written inside a documentation comment. The annotation affects compiler and API metadata; the lowercase Javadoc tag explains why the API was deprecated and what callers should use instead. Good library maintenance commonly uses both together.

The alternatives are not interchangeable. @Override checks that a method really overrides an inherited method, @SuppressWarnings hides selected compiler warnings, and @FunctionalInterface documents an interface intended to have one abstract method. None of those marks a method as deprecated.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: