Creating a documentation of a Java source file is not a big task, it can be done in just 3 steps which are explained below.
We use Javadoc tool to create documentation API for a java source file. Let's create a file with class name Documenttool and save this file with name Documenttool.java
Sample code:
Step 1: write a class and save it with .java as file extension (say Documenttool.java)
public class Documenttool {
public static int sum(int a , int b){
return (a + b);
}
public static int minus(int a , int b){
return (a - b);
}
}
Step 2: compile the file using the below command
javac Documenttool.java
Step 3: Now use the javadoc tool as below
javadoc Documenttool.java
Now, we can see in the current directory that a file is created with name Documenttool.html. On opening the Documenttool.html file in a text editor we will see that the Documenttool class is explained through documentation comment. Also, we can see the Documenttool.html in a browser.
0 Comment(s)