JavaDoc is a documentation generator tool provided by Java. It automatically creates professional HTML documentation from specially formatted comments written in Java source code.
/** and end with */@param, @return, @authorJavaDoc comments are placed directly above the element they describe. These comments are then processed by the javadoc command-line tool to generate HTML files.
/**
* This class demonstrates JavaDoc usage
* @author Admin
*/
public class Sample {
/**
* Adds two numbers
* @param a first number
* @param b second number
* @return sum of a and b
*/
public int add(int a, int b) {
return a + b;
}
}
Type in the code comments on the left to see how the HTML documentation updates in real-time on the right.
Calculates total price
Running the JavaDoc tool creates an HTML page containing:
javadoc Sample.javaindex.html in browser