The @Deprecated annotation can be used to indicate elements which should no longer be used. Any program that uses an element which is marked as @Deprecated will produce a compiler warning.

@Deprecated
public void oldMethod() {
  ...
}
public void newMethod() {
  ...
}

In this examples, newMethod replaces oldMethod. However we do not want to remove oldMethod completely because keeping it will help maintain backwards compatibility with older versions of the program.

We can keep oldMethod() and indicate to programmers that it should not be used in new versions by applying the @Deprecated annotation.