[JavaSE]->{注記と反射04}-->カスタム注記
6828 ワード
カスタム注記
前に書いてあります:このブログはノートの勉強にしか使いません.
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @ClassName: Test3
* @Description: //
* @Author: sniper-zx
* @Version: 1.0
**/
//
public class Test3 {
// /
@DiyAnnotation2(age = 19,name = "Tokm", id = 1,schools = {" "})
public void test1(){
}
@DiyAnnotation3(value = "Hi,nice to meet you!")
public void test2(){
}
}
// , {}
@Target(value = {ElementType.METHOD})
//
@Retention(value = RetentionPolicy.RUNTIME)
@interface DiyAnnotation2{
// ( )
String name() default "";
int age() default 19;
int id() default -1;//String indexOf("abc") -1 , ,
String[] schools() default {" "," "," "};
}
@Target(value = {ElementType.METHOD})
@Retention(value = RetentionPolicy.RUNTIME)
@interface DiyAnnotation3{
// , value
String value();
}
後に書きます:参考資料:【狂神説Java】注釈と反射