To create the document API of your java program use javadoc utility.Open your any java program for which you want to create api and then use document comment /** .... */ to post information about the class, its data method,data members ,constrcutor,blocks etc.
Let's see the simple class that contains documentation comment.
package com.java-interview-preparations;
/** This class is a user-defined class that contains one methods areaRectangle.*/
public class MyFile{
/** The method method prints area of the rectangle based on length and width */
public static void areaRectangle(int l,int w){
System.out.println("Area = " + (l*w));
}
} // end of class
To create the document API, you need to use the javadoc utility followed by your java file name. For this there is no need to compile the javafile.
On the command prompt, you need to write:
javadoc MyFile.java
to generate the document api. Now, there will be created a lot of html files. Open the index.html file to get the information about the classes.
Let's see the simple class that contains documentation comment.
package com.java-interview-preparations;
/** This class is a user-defined class that contains one methods areaRectangle.*/
public class MyFile{
/** The method method prints area of the rectangle based on length and width */
public static void areaRectangle(int l,int w){
System.out.println("Area = " + (l*w));
}
} // end of class
To create the document API, you need to use the javadoc utility followed by your java file name. For this there is no need to compile the javafile.
On the command prompt, you need to write:
javadoc MyFile.java
to generate the document api. Now, there will be created a lot of html files. Open the index.html file to get the information about the classes.
No comments:
Post a Comment