O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting ready

The @Deprecated annotation was first introduced in Java 5, while the Javadoc tag @deprecated was introduced in Java even earlier. The presence of the annotation forces the compiler to generate a warning that can be suppressed by the annotation:

@SuppressWarnings("deprecation")

Since Java 9, the annotation can have one or both the methods, namely since() and forRemoval():

@Deprecated(since = "2.1", forRemoval = true)

The since() method allows the setting of the API version (as String). It depicts the API version from where the particular class or method was deprecated. If not specified, the default value of the since() method is "" (empty String).

The forRemoval() method depicts the intent to remove the marked element (if true ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required