//
sample
import java.lang.annotation.Annotation;
import tiger.annotation.MyTag;
public class TagTest {
@MyTag(name="MyTag",age=1)
public void test(){
}
public static void main(String[] args){
TagTest tt = new TagTest();
try {
Annotation[] annotation =tt.getClass().getMethod("test").getAnnotations();
for (Annotation tag :annotation) {
System.out.println("Tag is:" + tag);
System.out.println("tag.name()" + ((MyTag)tag).name());
System.out.println("tag.age()" + ((MyTag)(tag)).age());
}
} catch(NoSuchMethodException e) {
e.printStackTrace();
}
}
}
import java.lang.annotation.Annotation;
import tiger.annotation.MyTag;
public class TagTest {
@MyTag(name="MyTag",age=1)
public void test(){
}
public static void main(String[] args){
TagTest tt = new TagTest();
try {
Annotation[] annotation =tt.getClass().getMethod("test").getAnnotations();
for (Annotation tag :annotation) {
System.out.println("Tag is:" + tag);
System.out.println("tag.name()" + ((MyTag)tag).name());
System.out.println("tag.age()" + ((MyTag)(tag)).age());
}
} catch(NoSuchMethodException e) {
e.printStackTrace();
}
}
}