Problem Statement
You need to document your java classes so that it helps in maintenance.
Solution
Use Javadoc and place comments before any method , field or class to document.
Just enter /** to start writing the comments using javadoc. The subsequent lines needs to begin with * and end the comment section with */
Below is a sample code demonstrating the usage of the javadoc for the comments.
package abundantcode;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/**
*
* @author Abundantcode
*
*/
public class abundantcodeconsole {
/**
* The main method that accepts input from the console and displays it
* @param args
*/
public static void main(String[] args) {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter data");
try {
String data = input.readLine();
System.out.println(data);
}
catch(Exception ex)
{
System.out.println(ex.getMessage());
}
Boolean b1 = Boolean.valueOf("false");
System.out.println(b1);
}
}The specific format defined above lets the developers to generate HTML documentation for the classes using the command-line tool called Javadoc. This tool parses the java source file and generates HTML documentation.
Eg :
javadoc abundantcodeconsole.java
You can also pass the complete package to the Javadoc tool instead of the single java file.
javadoc abundantcode
Leave a Reply