Reputation: 47
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.
Upvotes: 0
Views: 124
Reputation: 718826
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.)
Upvotes: 1
Reputation: 23
It is used when the JavaDoc is created for a specific class, because its in a comment block the compiler doesn't look at it, and it isn't used.
Upvotes: 0