Thursday 23 February 2017

Java Comments and Documentation




Java Comments And Documentation

One of the most important ways to improve the readability of your program is to use comments. These comments can help the developer understand why specific choices were made, who wrote the code, when it was written, code’s version or any information that explain the code. The compiler ignores comments while creating the bytecode.
Java allows three styles of comments in the source code.


1. Single-Line Comment:
If you need to produce a quick comment that fit on one line in your source code, this is the perfect kind of comment to use. You can use this style of comment before and after the line of code. The syntax is //, followed by whatever comment text you want. For example


System.out.println(“Hello World”);//will display the massage


2. Multi-Line Comment or Block Comment: this style of comment spans more than one line. The syntax for this comment is to start the block with /* and end with */. For example


/*
This is our first sample program
*/


3. Documentation Comment: This is a special form of block comment. The syntax for this comment is to start the block with /** and end with */. For example


/**
This is our first sample program
@ author shahbaz Ali
@version 1.0
*/


This type of comment is used by java’s documentation tool Javadoc. The documentation comment also allows us to use special standard tags for information such as the author of the code, the version and other details. Javadoc produces HTML documents that will be part of the documentation of the application.


 Next Topic Shahbaz

0 comments:

Post a Comment

Powered by Blogger.

Stats