今天试用广州宏天的joffice,下载1.2版本的源码后,导入myeclipse。编译器提示:@Override错误,其他annotation没有问题。上网查找资料发现,@override注释在jdk1.5环境下只能用于对继承的父类的方法的重写,但不能用于对实现的接口中的方法的实现。(也就是jdk1.5的 @Override 这个annotation
要求为API文件@Documented 想要在使用者制作javaDoc文件的同时,也一并将Annotation的信息加入至API文件中,使用java.lang.annotation.Documented 范例: @Documented public @interface DocumentedAnnotation{
限定Annotation使用对象@Target 使用java.lang.annotation.Target可以定义其使用之时机。在定义时要指定java.lang.annotation.ElementType的枚举值之一。 package java.lang.annotation; public enum ElementType{
型态时,指示编译程序该如何对待您的自定义Annotation信息留在.class型态时,需要提供java.lang.annotation.RetentionPolicy后就完成任务 CLASS; //档中,缺省
定义Marker Annotation,也就是Annotation名称本身即提供信息于对程序分析工具来说,主要是检查是否有Marker Annotaion的出现,并作出对应的动作。 1. 定义简单的Annotation: public @interface AnnotationTest{ } 使用:
l Annotation的由来 l Annotation的定义方式 l Annotation的使用方式 l
Copyright © 2005-2024 51CTO.COM 版权所有 京ICP证060544号