Creating API document | javadoc tool

Creating API document | javadoc tool

 

In Java programming language the documentation comment is used to create the documentation API. We use the javadoc tool to create a documentation API.

The following is the syntax of the documentation comment in Java:

 

Syntax:

The documentation comment is used in java programming language in the following way:

/**

Adding a documentation

comment in

our program

*/

 

Example of documentation comment in Java:

Consider the following example in which we added the documentation comment to add information to our program:

CODE:

/** In this class we will be performing addition of two integers. */

public class addition {

/** using the add method to return the sum of two integers. */

public static void add (int a, int b) {

return a + b;

}

}

The above program will be compiled by using the following command:

javac addition. java

Now we will create the documentation API by using the javadoc tool. Use the following command to create the documentation API:

javadoc addition. java

In this way the html file will be created for the class that was named as addition in the current directory. When we open that html file then the explanation that was added by us as the documentation comment will be displayed of the class “addition”. Remember that this API was provided by the documentation comment.