它的作用是对不应该再使用的方法添加注解,当编程人员使用这些方法时,将会在编译时显示提示信息,它与javadoc里的@deprecated标记有相同的功能,准确的说,它还不如javadoc @deprecated,因为它不支持参数,使用@Deprecated的示例代码示例如下:
/** * 测试Deprecated注解 * @author Administrator */ public class DeprecatedDemoTest { public static void main(String[]args) { // 使用DeprecatedClass里声明被过时的方法 DeprecatedClass.DeprecatedMethod(); } } class DeprecatedClass { @Deprecated public static void DeprecatedMethod() { } }