Comments

Save & Share

 

 

 

 

 

 

 

 

 

Java has three kinds of comments: traditional comments, end-of-line comments and documentation comments.

 

Examples: Traditional comments start with /* and end with */, they may span across multiple lines. This type of comments was derived from C and C++.

 

   1:  /* This is a multi-line comment.
   2:  It may occupy more than one line. */

 

End-of-line comments start with // and extend to the end of the current line. This comment type is also present in C++ and in modern C.

 

   1:  // This is an end-of-line comment

 

Documentation comments are processed by Javadoc tool to generate documentation from source files. This type of comments is identical to traditional comments, except it starts with /** and follows conventions defined by the Javadoc tool. Technically these comments are a special kind of traditional comments and they are not specifically defined in the language specification.

 

   1:  /**
   2:   * This is a documentation comment.
   3:   * 
   4:   * @author John Doe
   5:   */

The text content of this page derived from wikipedia.org Java syntax page and available under the Creative Commons Attribution-ShareAlike License.  The original work has been modified.

Posted in Basics • • Top Of Page