Java-notes documents

Source: Internet
Author: User
Tags return tag

1. Note: during compilation, everything between/* and */is ignored. Each line of the continuous comment content starts with.

2. annotation document: placing codes and documents in the same file facilitates unified management of the two. This requires a special annotation syntax and a tool for extracting annotations.

The tool used to extract comments: javadoc, which searches for special annotation tags in the program, parses the information marked by these tags, and extracts the class name or method name adjacent to the annotation.
Javadoc outputs an HTML file. With javadoc, the document creation standard is available.

Annotation Syntax: javadoc can only appear in/** and */Annotations. There are two ways to use javadoc: (1) embed HTML (2) use "document tag ".
Independent document label: a command starting with "@" and placed at the beginning of the comment line.
In-line document labels: commands starting with "@" can appear anywhere in the javadoc comments, but must be enclosed in curly brackets.
There are three types of annotation documents, which correspond to the three elements following the annotation position: Class, variable, and method. that is, the class annotation is located before the class definition; the variable annotation is located before the variable definition; the method annotation is located just before the method definition.

Javadoc can only comment documents for public and protect members. Private and comments for accessible members in the package are ignored. only public and protect members can be used outside the file. all comments made to the class are included in the output result.

Embedded HTML: The main purpose is to format the code and comments.
In the document comment, asterisks and leading spaces at the beginning of each line are discarded by javadoc. javadoc reformats all the content to make it look consistent with the standard document. do not use title tags in embedded HTML, such as <HL> <HR>, because javadoc inserts its own title, and your title may conflict with them.

Javadoc tag example
@ Version label
Format: @ version-Information
If the javadoc command line uses the "-version" mark, extract the published version information (version-information) from the generated HTML document ).

@ Author label
Format: @ author-Information
If the javadoc command line uses the "-Author" mark, the author information (author-information) is extracted from the generated HTML document ).
Multiple tags can be used to list all authors, but they must be placed continuously. All author information is merged into the same paragraph and placed in the generated HTML.

@ Param label
Format: @ Param parameter-Name Description This label is used in the method documentation.

@ Return tag
Format: @ return description this label is used in the method document.

@ Throws tag
Format: @ throws fully-qualified-class-Name Description
Fully-qualified-class-name indicates the unambiguous name of the exception class. description tells you why the exception class appears in the method call.

//: C02: hellodate. Java
Import java. util .*;

/***//**
* Title: hellodate class <br>
* Description: Describes Java document comments using the hellodate class. <br>
* Description: display a string and today's date <br>
* Copyright: (c) 2008 forest he <br>
* Company: qunshuo <br>
* @ Author Bruce Eckel
* @ Author www.bruceeckel.com
* @ Version 2.0
*/
Public class hellodate ...{
/***//**
* Sole entry point to Class & Application
* @ Param ARGs array of string arguments
* @ Return no return value
* @ Exception no exceptions thrown
*/
Public static void main (string [] ARGs )...{
System. Out. println ("Hello, it's :");
System. Out. println (new date ());
}
}///:~

The first line uses its own unique method and uses a ":" as a special mark to indicate that this is a comment line containing the source file name. this row contains the path information of the file (section 2nd for C02), followed by the file name. comment on the last line "///:~ "Indicates the end of the source code list.

Encoding style: the first letter of a class name must be capitalized. If a class name consists of several words, combine them (that is, do not use underscores to separate names ), the first letter of each internal word is in uppercase.
This style is called "camper style ". for all other content (methods, member variables, Object Reference names, etc.), the accepted style is the same as the class style, but the first letter of the identifier must be in lower case.

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.