Comments in Java code



Comments in Java code is intended for human readers as well as generating documentation of the code.
There are three types of comments you can make in the code:

Single-line comment

The single line comment starts with two slashes and that indicates that the rest of the current line is commented out.

Multiple-line comment

Multi-line comments starts with the characters /* and ends with the characters */.
Any text placed between the start and the end is ignored by the compiler regardless of how many rows that are commented out.
For example:

This type of comment can of course also be used when commenting a single line:

Doc comment

The third type is a variation of the previous. It is used to comment for example methods to be used by the doc generator (javadoc) when auto generating API documentation in HTML format.







Search for more Java info on this site here:
Custom Search


Please type any questions here.