java里面的Annotation的使用
来源:互联网 发布:软件测试转正心得体会 编辑:程序博客网 时间:2024/04/30 10:14
eclipse里面建工程, 三个source文件
package com.sap;import java.lang.annotation.*;@Target(ElementType.PACKAGE)@Retention(RetentionPolicy.RUNTIME)public @interface PkgAnnotation {String value();String desc();}
@PkgAnnotation(value="anno value", desc="i am description for annotation")package com.sap;
package com.sap;import java.lang.annotation.*;public class Client {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stubPackage pkg = Package.getPackage("com.sap");boolean flag = pkg.isAnnotationPresent(PkgAnnotation.class);if (flag){Annotation[] annos =pkg.getAnnotations();for(Annotation an : annos){if (an instanceof PkgAnnotation){System.out.println(((PkgAnnotation) an).value());System.out.println(((PkgAnnotation) an).desc());}}}}}
输出:
anno value
i am description for annotation
- java里面的Annotation的使用
- Java注解Annotation的使用
- 使用Java内置的Annotation 和 自定义的Annotation
- 写数据到的Annotation Featureclass里面
- 重新设置testNG里面的annotation
- Java自定义注解Annotation的使用
- 【Java】注解 annotation的介绍与使用
- java注解Annotation的使用实例
- java Annotation的使用和分析
- java注解annotation使用的一点建议
- 【java】:java里面super变量的使用
- hibernate3 Annotation的使用
- Struts2的Annotation使用
- annotation注解的使用
- Struts2的Annotation使用
- Annotation的基本使用
- Struts2的Annotation使用
- Struts2的Annotation使用
- 关于getchar()函数_1
- 直接删除数据文件后无法进入系统的解决方案
- 关于随机数_5
- Config log4j in standalone app
- 353. Penny wise, pound foolish. 贪小便宜吃大亏
- java里面的Annotation的使用
- HBase源代码调试(1)
- Mac 系统常用快捷键
- 第五篇 对话框控件的使用
- Python3 批量转换文件编码 Encoding
- JAVA中的两种典型排序,选择和冒泡
- 谨以这篇文章作为我编程道路的目标,规范和准则!
- ctypes 加载的so库中函数参数的字符串传递问题(str与bytes转换)
- Android之Handler用法总结