How to write, generate and use Javadoc in Eclipse

How to write, generate and use Javadoc in Eclipse.

During programming any decent programmer documents what he or she writes. Java programmers use for this task Javadoc. In code it looks like multiple-line comment, but between the two is a significant difference.

Multiple-line comment starts with slash followed by single asterisk. Javadoc starts with slash followed by two asterisks.

You type Javadoc before the structure you want to comment. It can be a class, attribute or method. Method is especially interesting. On method you can comment not only what it does, but also its input and output.

For creation of Javadoc use Eclipse like this:

type slash, two asterisks and press enter. It will generate a structure, where you just fill in your documentation.

When you comment using Javadoc, you can use this documentation in two ways. You can access it in your IDE during development. Or you can generate HTML documentation. Select your project, click Project, Generate Javadoc and don't forget to set path to javadoc.exe command in your JDK.

In this HTML documentation you have screen divided into three parts: packages, classes and the detail of selected class.

Creators of Java also used Javadoc for documentation. Just google Java api 7 and you will easily find documentation for Java 7.