Sometimes, we write classes that are compiled into a. class file for others to use, so that others don't know what methods the class has, how to invoke it.
So we need to do a description of the class document.
You can use annotations in the. Java class to generate a description of the class's method.
First,. The notation in Java:
Test1.java
/*Document Comments*//**This class is an array that takes the most value, sorts, and so on.@authorZhang San@version1.0*/ Public classtest1{/**take the maximum value inside the int array@paramarr passes an array of int@returnreturns an int value*/ Public Static intMaxint[] arr) { intj = arr[0]; for(inti=0;i<arr.length;i++){ if(j<Arr[i]) {J=Arr[i]; } } returnJ; } /**take the minimum value inside the int array@paramarr passes an array of int@returnreturns an int value*/ Public Static intXint[] arr) { intj = arr[0]; for(inti=0;i<arr.length;i++){ if(j>Arr[i]) {J=Arr[i]; } } returnJ; }}
Ps:
Note Start with/**, with */end
@author author
@version version
@param arr The value passed in (Arr is the method parameter name, what is the parameter name, what is filled out here, followed by "Incoming value", these words are a description of the parameter name)
The value returned by the @return (returns what to fill in, preceded by the words "returned value" is a description of the return value)
Note: This class is written to public otherwise it cannot generate the description document
Second, in DOS, use the following command to generate the documentation
javadoc-d mydoc1-author-version Test1.java
Ps:
1, the above command Mydoc1 is the generated file save directory
2.-author is the author of the generation
3,-version is the generation version number
Iii. post-generated description document file structure:
After the build, the saved file is a Web page file. html, double-click index.html to open the browser to view
To see the effect:
In this document, there is a description of the constructor, if we need to cancel, we just need to define the constructor as private, you can, the code is as follows:
/*Document Comments*//**This class is an array that takes the most value, sorts, and so on.@authorZhang San@version1.0@adddate 2015-05-31*/ Public classtest1{PrivateTest1 () {}/**take the maximum value inside the int array@paramarr passes an array of int@returnreturns an int value*/ Public Static intMaxint[] arr) { intj = arr[0]; for(inti=0;i<arr.length;i++){ if(j<Arr[i]) {J=Arr[i]; } } returnJ; } /**take the minimum value inside the int array@paramarr passes an array of int@returnreturns an int value*/ Public Static intXint[] arr) { intj = arr[0]; for(inti=0;i<arr.length;i++){ if(j>Arr[i]) {J=Arr[i]; } } returnJ; }}
JAVA documentation Comments, descriptions of classes, generation of HTML explanatory documents