1. 程式人生 > 資訊 >大眾汽車被晶片問題“卡脖子”,銷量降至十年來最低

大眾汽車被晶片問題“卡脖子”,銷量降至十年來最低

元註解

  • 元註解的作用就是負責註解其他註解,Java定義了4個標準的meta-annotation型別,他們被用來提供對其他annotation型別作說明

  • 這些型別和它們所支援的類在java.lang.annotation包中可以找到.(@Target,@Retention,@Documented,@Inherited)

    • @Target:用於描述註解的使用範圍(即:被描述的註解可以用在什麼地方)

    • @Retention:表示需要在什麼級別儲存該註釋資訊,用於描述註解的生命週期

      • (SOURCE<CLASS<RUNTIME)

    • @Document:說明該註解將被包含在javadoc中

    • @Inherited:說明子類可以繼承父類中的該註解

package com.hua.annotation;

import java.lang.annotation.*;

//測試元註解
@MyAnnotation
public class Test02 {

    @MyAnnotation
    public void test(){

    }
}

//定義一個註解
//Target 表示我們的註解可以用在哪些地方
@Target(value ={ElementType.METHOD,ElementType.TYPE})

//Retention 表示我們的註解在什麼地方還有效
//runtime>class>source @Retention(value= RetentionPolicy.RUNTIME) //@Documented 表示是否將我們的註解生成在JAVAdoc中 @Documented //@Inherited 子類可以繼承父類的註解 @Inherited @interface MyAnnotation{ }
我的一生 第1章-廢物的一生 第50章-糟糕的嬰兒 第300章-莫欺少年窮 第600章-莫欺中年窮 第1000章-莫欺老年窮 第1100章-不詳的離去 第1101章-棺材板的震動 第1150章-盜墓賊的眼淚 第1200章-死者為大