Two new parameters or properties have been added in the @Deprecated annotation in Java 9. These parameters are Since and forRemoval, these two parameters are optional when we cannot specify them, with default values.
this string parameter specifies a deprecated version of the API. The default value for this element is emptystring.
<strong>@Deprecated(since="<version>")</strong>
This Boolean parameter specifies whether the API is intended to be removed in a future release. When we cannot specify, the default value is false.
<strong>@Deprecated(forRemoval=<boolean>)</strong>
public class DeprecatedAnnotationTest { public static void main(String[] args) { DeprecatedAnnotationTest test = new DeprecatedAnnotationTest(); test.method1(); test.method2(); } <strong> @Deprecated(since="7.0")</strong> public void method1() { System.out.println("@Deprecated(since=\"7.0\")"); } <strong> @Deprecated(since="5.0", forRemoval=true)</strong> public void method2() { System.out.println("@Deprecated(since=\"5.0\", forRemoval=true)"); } }
<strong>@Deprecated(since="7.0") @Deprecated(since="5.0", forRemoval=true)</strong>
The above is the detailed content of What properties does the @Deprecated annotation add in Java 9?. For more information, please follow other related articles on the PHP Chinese website!