java注解和反射– 内置注解

java
Author

dd21

Published

December 5, 2022

内置注解

在这里插入图片描述
package cn.usts.edu.InnerAnnotation;

import java.util.ArrayList;
import java.util.List;

/**
 * 内置注解
 * */
public class InnerAnnotation extends Object{

    @Override  // 重写注解
    public String toString() {
        return "重写的toString";
    }

    @Deprecated // 不推荐程序员使用,或者有更好的方法
    public void test01(){
        System.out.println("test01");
    }

    @SuppressWarnings("all") // 镇压警告
    public void test02(){
        List list = new ArrayList(); // 要不然这里会警告
        System.out.println("test03");
    }

    public static void main(String[] args) {
        InnerAnnotation innerAnnotation = new InnerAnnotation();
        innerAnnotation.test01();
    }
}