1. 程式人生 > 遊戲攻略 >《原神攻略》萃華木分辨及採集攻略

《原神攻略》萃華木分辨及採集攻略

package annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

//自定義註解
public class Test03 {
//註解可以顯示賦值,如果沒有預設值,我們就必須給註解賦值
@MyAnnotation2(name = "aaa",schools = {"哈工大,哈理工"})
public void test(){}
@MyAnnotation3("秦姜")
public void test2(){}
}

//需要元註解
@Target({ElementType.TYPE,ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@interface MyAnnotation2{
//註解的引數:引數型別+引數名();
String name() default "";
int age() default 0;
int id() default -1;//如果預設值為-1,代表不存在
String[] schools() default {"西部開源","清華大學"};
}
//需要元註解
@Target({ElementType.TYPE,ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@interface MyAnnotation3{
String value();//當註解只有一個引數的時候 建議使用value()當引數名字,因為 當使用的時候就可以省略引數名
}