The Java programming language supports three kinds of comments:
/* text */
The compiler ignores everything from /* to */.
/** documentation */
This indicates a documentation comment (doc comment, for short).
The compiler ignores this kind of comment, just like it ignores comments that use /* and */.
The JDK javadoc tool uses doc comments when preparing automatically generated documentation.
// textThe compiler ignores everything from // to the end of the line.
Example
Java denotes comments in three ways:
1. Double slashes in front of a single line comment:int i=5; // Set the integer to 5
2. Matching slash-asterisk (/*) and asterisk-slash (*/) to bracket multi-line comments:/*Set the integer to 5*/int i=5;
3. Matching slash-double asterisk (/**) & asterisk-slash(*/) for Javadoc automatic hypertext documentation, as in
/**This applet tests graphics.*/
public class testApplet extends applet
{
...or
/**
*Asterisks inside the comment are ignored by javadoc so they
* can be used to make nice line markers.
**/
The SDK tool javadoc uses the latter /** ..*/ comment style when it produces hypertext pages to describe a class.
Sunday, September 28, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment