Home / Programs / Documentation Comment in java
Programming Example

Documentation Comment in java

👁 3,096 Views
💻 Practical Program
📘 Step by Step Learning

In this section we will discuss about documentation comment in java programming language

Information & Algorithm

The Java language supports three types of comments.

Sr.No. Comment & Description
1

/* text */

The compiler ignores everything from /* to */.

2

//text

The compiler ignores everything from // to the end of the line.

3

/**
* documentation */

This is a documentation comment and in general its called doc comment. The JDK javadoc tool uses doc comments when preparing automatically generated documentation.

Program Code

 /**
* This is Documentation Section in java
* Program Name     : How to declare and initialize a variable 
* Program Author   : Rumman Ansari
* Program Date     : 12.02.2001
* output           : it will print value of variable j
*/
	
public class MultiLineComment {
public static void main(String[] args) {
/* it's a multiline comment, we are going to
declare and  print variable j . */
    int j=10;
    System.out.println(j);
 }
}

Output

10
Press any key to continue . . .

Explanation

Documentation comments in Java are special comments that begin with /** and end with */. These comments are used to document Java source code in a standardized format, known as JavaDoc. JavaDoc comments are used to generate API documentation, which describes the behavior of classes, methods, and fields in Java code.

JavaDoc comments can include a variety of information, including the author, version, and parameters of a method, as well as examples of how to use the method. JavaDoc comments are used to provide a clear and concise description of what a method does, what it expects as input, and what it returns as output.

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.