Java注释教程
我参与了一个使用注释的Java项目。是否可以开发自定义注释,或者仅限于Java框架已经设置的注释
如果web上有任何优秀的Java注释教程可以展示如何构建自定义注释,请有人向我提供该链接
我这样问是因为我相信这是我充分理解注释的最好方式
你可以在下面搜索框中键入要查询的问题!
我参与了一个使用注释的Java项目。是否可以开发自定义注释,或者仅限于Java框架已经设置的注释
如果web上有任何优秀的Java注释教程可以展示如何构建自定义注释,请有人向我提供该链接
我这样问是因为我相信这是我充分理解注释的最好方式
# 1 楼答案
可以自己构建注释,它们基本上是特殊的接口。查看甲骨文网站上的Lesson: Annotations,了解如何自己构建它们
提示:找到这个链接就像在谷歌上搜索“java注释教程”一样简单。你可以用同样的方法找到其他的
# 2 楼答案
您可以创建自己的注释以满足需要
这里有一个不错的教程:
http://www.aviyehuda.com/blog/2009/12/29/create-your-own-java-customized-annotations/
以下是您可能创建的新创建注释的一些元注释:
元注释实际上是注释使用的注释
-@Target–指定此注释附加到的元素类型
-@Retention–指定此批注的保留级别
-@Documented–默认情况下,java文档中会提到注释,此元注释将使此注释被提及
-@Inherited–表示注释将自动被继承