首页 > 学院 > 开发设计 > 正文

自定义注解

2019-11-11 04:58:49
字体:
来源:转载
供稿:网友
package annotation;import java.lang.annotation.Documented;import java.lang.annotation.ElementType;import java.lang.annotation.Inherited;import java.lang.annotation.Retention;import java.lang.annotation.RetentionPolicy;import java.lang.annotation.Target;@Target({ElementType.METHOD,ElementType.FIELD,ElementType.TYPE})//使用时的作用域(方法,字段,类)@Retention(RetentionPolicy.RUNTIME)//注解在程序运行时的声明周期@Inherited//允许被子类继承@Documented//生成javadoc文档时包含的注解public @interface MyAnnou {// String value();当注解只有一个变量时,规定成员名为value,使用时忽略成员名和赋值符号‘=’ String str() default ("");//多个变量用关键字default付初始化值}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表