Home > Articles

  • Print
  • + Share This
This chapter is from the book


Java provides three styles of comments:

/* This is a
  multiline comment. */

// This is a single-line comment.

/** This is a
  multiline javadoc comment */

The first comment style supports traditional C-language comments. All text that appears between /* and */ is treated as a comment. Comments of this style can span multiple lines.

The second comment style supports single line C++ comments. All text following the // until the end of the line is treated as a comment.

The third comment style is used by the javadoc documentation generation tool. All text between the /** and */ is treated as a javadoc comment. javadoc comments can span multiple lines. You do not need to know about javadoc on the certification exam. However, if you are interested, javadoc is described in the "Tools" section of the Java 2 platform documentation.

Comments cannot be nested. If comments appear within a String or character literal, they are treated as part of the String or literal.

  • + Share This
  • 🔖 Save To Your Account