Is javadoc comment a type of standard java comment?
How many types of java comments are there? Everybody knows there are two types of java comments available. Now the misunderstood part starts. What are those two types of java comments?
The (§3.7) Java Language Specification Third Edition says,
- Traditional Comment
- End of line Comment
What happened to the documentation comment or javadoc comment?
No it is not a type by itself. This is a commonly misunderstood theory in Java. First lets go through the defintion of these two types of java comments as per specification.
1) Traditional Comment
/* text */
Definition: All the text from the ASCII characters /* to the ASCII characters */ is ignored (as in C and C++).
2) End of line Comment
Definition: all the text from the ASCII characters // to the end of the line is ignored (as in C++).
Java comments come with the following properties too:
- Nested comments are not possible
- /* and */ have no special meaning in comments that begin with //
- // has no special meaning in comments that begin with /* or /**
- And also the lexical grammar implies that comments do not occur within character literals (§3.10.4) or string literals (§3.10.5)
Javadoc tool facilitates the extraction of text added in the java source code between /** and */. The syntax used is /** text */
Now the compiler point of view. When the java compiler encounters /* it ignores the text until it reaches */ Therefore irrespective, it might be /** or /*# or any other character java compiler doesn’t takes that into account. For the java compiler it is a traditional comment.
Therefore as per Java Language Specification Third Edition there is no special type as java documentation comment.
This Core Java tutorial was added on 23/07/2008.