I was wondering what exactly anotations are used for in Java, I have a basic understanding of it. However my true question is, what does annotions mean when their in a comment? For example: /** @param **/
. Does it have any effect in the code itself?
Thank you.
I was wondering what exactly anotations are used for in Java
They are used for all sorts of things. It is not possible to give an "exact" answer, because the use-cases for annotations are (literally) infinite. And besides, you have probably seen a few use-cases already. (Google for examples, if you want to find more ...)
However my true question is, what does annotions mean when their in a comment?
When they are in comments, they are not annotations. In this case, they are javadoc tags ... which are used when generating the javadoc documentation for the code,
For example: /** @param **/. Does it have any effect in the code itself?
It has no effect on the code itself. A Java compiler ignores anything in Java comments. (Of course, it is possible to write a compiler for a Java-derived language that pays attention stuff in comments. But that ain't Java.)
当为特定类创建JavaDoc时使用它,因为在注释块中编译器不会查看它,也不会使用它。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.