JAVA documentation Comments, descriptions of classes, generation of HTML explanatory documents

Source: Internet
Author: User
Tags sorts

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.