package Study.Annotation;
import java.lang.annotation.*;
import java.util.Set;
import javax.annotation.*;
@IcastAnnotation
public class MyAnnotation {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
sayHello();
if(MyAnnotation.class.isAnnotationPresent(IcastAnnotation.class)==true)
{
Annotation[] annot= IcastAnnotation.class.getAnnotations();
for(int i=0;i<annot.length;i++)
{
System.out.println(annot.length+annot[i].getClass().getName().toString());
}
System.out.println("ss");
}
}
@Deprecated
public static void sayHello()
{
System.out.println("hhhhh");
}
}
----------------------------------------------------------------------
package Study.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface IcastAnnotation {
}
----------------------------------------------------------------------
如何获取注释的名字呢??????? |
|