")forRemoval This boolean parameter specifies whether the API is intended to be removed in a future version. When we cannot specify it, the default value is false. Syntax@Deprecated(forRemoval= Home >Java >javaTutorial >What properties does the @Deprecated annotation add in Java 9? 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. 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. 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!What properties does the @Deprecated annotation add in Java 9?
Because
Syntax
<strong>@Deprecated(since="<version>")</strong>
forRemoval
Syntax
<strong>@Deprecated(forRemoval=<boolean>)</strong>
Example
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)");
}
}
Output
<strong>@Deprecated(since="7.0")
@Deprecated(since="5.0", forRemoval=true)</strong>