What is JavaDoc tool and how to use it?

JavaDoc tool is a document generator tool in Java programming language for generating standard documentation in HTML format. It generates API documentation. It parses the declarations ad documentation in a set of source file describing classes, methods, constructors, and fields.

Before using JavaDoc tool, you must include JavaDoc comments /**………………..*/ providing information about classes, methods, and constructors, etc. For creating a good and understandable document API for any java file you must write better comments for every class, method, constructor.

The JavaDoc comments is different from the normal comments because of the extra asterisk at the beginning of the comment. It may contain the HTML tags as well.

// Single-Line Comment

/*
* Multiple-Line comment
*/

/**
* JavaDoc comment
*/

By writing a number of comments, it does not affect the performance of the Java program as all the comments are removed at compile time.

JavaDoc Format: –
It has two parts: – a description which is followed by block tags.
Some Integrated Development Environments (IDE) automatically generate the JavaDoc file like NetBeans, IntelliJ IDEA, Eclipse, etc.

Generation of JavaDoc: –
To create a JavaDoc you do not need to compile the java file. To create the Java documentation API, you need to write Javadoc followed by file name.

javadoc file_name or javadoc package_name

After successful execution of the above command, a number of HTML files will be created, open the file named index to see all the information about classes.

JavaDoc Tags

Tag Parameter Description
@author author_name Describes an author
@param description provide information about method parameter or the input it takes
@see reference generate a link to other element of the document
@version version-name provide version of the class, interface or enum.
@return description provide the return value

To generate JavaDoc in Eclipse: –

Example 1: –