您好,欢迎访问一九零五行业门户网

在Java 9中,@Deprecated注解添加了哪些属性?

java 9 中的 @deprecated 注释 中添加了两个新参数或属性。这些参数是 since 和 forremoval,这两个参数当我们无法指定时,两个参数是可选的,带有默认值。
因为此字符串参数指定api 已弃用的版本。此元素的默认值为空字符串。
语法@deprecated(since="<version>")
forremoval此布尔值参数指定是否打算在未来版本中删除该 api。当我们无法指定时,默认值为false。
语法@deprecated(forremoval=<boolean>)
示例public class deprecatedannotationtest { public static void main(string[] args) { deprecatedannotationtest test = new deprecatedannotationtest(); test.method1(); test.method2(); } @deprecated(since="7.0") public void method1() { system.out.println("@deprecated(since=\"7.0\")"); } @deprecated(since="5.0", forremoval=true) public void method2() { system.out.println("@deprecated(since=\"5.0\", forremoval=true)"); }}
输出@deprecated(since="7.0")@deprecated(since="5.0", forremoval=true)
以上就是在java 9中,@deprecated注解添加了哪些属性?的详细内容。
其它类似信息

推荐信息