Comments about Java

Source: Internet
Author: User
Tags comments documentation zip

For Java annotations We have two main types of knowledge:

Comment Line

///Comment several lines

But there's a third kind of documentation comment:

/** ... * * Comment several lines and write Javadoc documentation

Typically, the multiple lines of this annotation are worded as follows:

/**

* .........

* .........

*/

A lot of people ignore this third annotation, so what's the use of this third kind of annotation? What the hell is Javadoc? Let's talk about it below.

A. Java documentation and Javadoc

Java programmers should know that using JDK development, the best help information comes from SUN-published Java documents. It provides a detailed information on the various aspects of the law, the information of the attribute, the detailed tree-like information, the index and so on, and provides the relationship among many related classes, such as inheritance, implementation interface, reference, etc.

Java documents are all organized by a number of HTML files, and they can be downloaded on the SUM site. But you can't imagine that these documents can be built on our own. Stop and hang on to your appetite.

After the JDK is installed, there is a Src.jar file or Src.zip file under the installation directory, which are compressed in zip format and can be decompressed using WINZIP. After decompression, we can see that the sub directory is full of. java files. Yes, these are the Java running class source code, very complete, even the comments are written clearly ... But how does it feel to be familiar with these notes?

It is not surprising that our mystery is about to be uncovered. If you look carefully at the contents of the documentation Comments (/** ... * *) and the Java document in the Java source file, you will find that they are the same. Java documents are just a little bit more in format and typography. A little more careful, you'll find. The annotations in the Java source file also have HTML identifiers, such as ,
, , and so on, where the identifiers appear in the Java document, and are already formatted by the definition of the identity.

Finally, the original Java document is from these annotations. No wonder these comments are called documentation comments! But what is the tool that turns these annotations into documents?

It's time for the Javadoc to come out. You can find Javadoc in the JDK's Bin directory, and if it is a JDK under Windows, its file name is Javadoc.exe. When you compile a. Java source file using Javdoc, it reads the documentation comments from the. Java source file, compiles with Java source programs, and builds the document in accordance with certain rules.

Before you introduce the compilation commands for Javadoc, let's take a look at the format of the documentation comments. However, in order to be able to compile a few examples mentioned below, here is an introduction to the Javadoc command:

javadoc-d Document storage directory-author-version source filename. java

This command compiles a Java source file named "source filename. java" and stores the resulting document in the directory specified in the document storage directory, where index.html is the first page of the document. -author and-version Two items can be omitted.

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.