读书人

@Retention诠注功能使用

发布时间: 2012-10-27 10:42:26 作者: rapoo

@Retention注解功能使用
Retention提供了java.lang.annotation.RetentionPolicy的列举

package test;import java.lang.annotation.*;@Target({ElementType.FIELD,ElementType.METHOD,ElementType.PARAMETER})   //用于字段,方法,参数@Retention(RetentionPolicy.RUNTIME) //在运行时加载到Annotation到JVM中public @interface Field_Method_Parameter_Annotation {    Class type() default void.class;  //定义一个具有默认值的Class型成员    String describ();    //定义一个没有默认值的String成员    String name() default ""; //字段属性名称}

读书人网 >编程

热点推荐