1 @OVerride:指定方法覆载,它强制一个子类必须覆盖父类方法
package ThrowableTest; class Apple { public void info() { System.out.println("zhegeshuiguode1shipingguo"); } } public class Fruit extends Apple{ @Override public void info() { System.out.println("zhegeshuiguode1xinxishi:"); } }
[email protected]:表示某个程序元素(类、方法)已过时
package ThrowableTest; class Apple1 { //定义info方法已过时 @Deprecated public void info() { System.out.println("打鼾王"); } } public class DeprecatedTest { public static void main(String[] args) { new Apple1().info(); } }
3 @SuppressWarnings
指示该Annotation修饰的程序元素取消编译器警告
时间: 2024-09-29 23:43:45