Is javadoc comment a type of standard java comment?

23/07/2008

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:

  • 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
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.

Ads by Google

4 comments on “Is javadoc comment a type of standard java comment?

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

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Ads by Google
ABOUT
I am Joe, author of this blog. I run javapapers with loads of passion. If you are into java, you may find lot of interesting things around.
Ads by Google
STAY in TOUCH:

Email:

Core Java | Servlet | JSP | Design Patterns | Android | Spring | Web Service | © 2008-2012 javapapers.