10x Blogs Directory

Thursday, February 19, 2009

Java Comments

  • Comments
    -These are notes written to a code for documentation purposes.
    -Those texts are not part of the program and does not affect the flow of the program.
  • 3 Types of comments in Java
    -C++ Style Comments
    -C Style Comments
    -Special Javadoc Comments

C++-Style Comments

  • C++ Style comments starts with //
  • All the text after // are treated as comments
  • For example: // This is a C++ style or single line comments

C-Style Comments

  • C-style comments or also called multiline comments starts with a /* and ends with a */.
  • All text in between the two delimeters are treated as comments.
  • Unlike C++ style comments, it can span multiple lines.
  • For example: /* this is an exmaple of a C style or multiline comments */

Special Javadoc Comments

  • Special Javadoc comments are used for generating an HTML documentation for your Java programs.
  • You can create javadoc comments by starting the line with /** and ending it with */.
  • Like C-style comments, it can also span lines.
  • It can also contain certain tags to add more information to your comments.
  • For example: /** This is an example of special java doc comments used for \n generating an html documentation. It uses tags like: @author Vignesh @version 1.5*/