Is javadoc comment a type of standard java comment?

Last modified on December 20th, 2008 by Joe.

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,

  1. Traditional Comment
  2. 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
// text
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:

Javadoc Tool
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.

Comments on "Is javadoc comment a type of standard java comment?"

  1. Jayaraj says:

    Good

  2. Anonymous says:

    good explanation

  3. Anonymous says:

    Pls also put a tutorial on “How Annotations Work in Java”.

  4. Shailej says:

    Very good Explained Document.

Comments are closed for "Is javadoc comment a type of standard java comment?".