国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home Java Javagetting Started Introduction to javadoc specification

Introduction to javadoc specification

Jan 25, 2021 am 09:49 AM
javadoc specification

Introduction to javadoc specification

Introduction:

We know that javadoc is embedded in the JDK, so following the javadoc specification is definitely the orthodoxy of java annotations. Generating API documentation with the help of javadoc is Very practical.

(Learning video sharing: java video tutorial)

1. What are comments

Comments are to make the code more It is readable and reduces the communication cost of teamwork. In a team, if your code is clearer, more readable, and more standardized, then promotion and salary increase will definitely be yours, because you can be compatible with more people.
I heard a saying some time ago: If only you can understand your code, then you are the indispensable person. The person who said this is stupid. Only he can read and understand the code he writes. No one wants to see him. He lives like a grandson. Does everyone need a grandson?

2. Commonly used comment shortcut keys

Comment a line: //I am the content of the line
Shortcut key: ctrl/Reverse operation: ctrl/Comment a block:/*I am the content of the block* /
Shortcut key: ctrl shift / Reverse operation: ctrl shift \javadoc Recognizable comments:

	/**
	 * 我是注釋
	 * 我也是注釋
	 * 我還是注釋,我們都能被javadoc識別
	 */

3, javadoc specification

Follow the javadoc specification, we can use the javadoc command, It is very convenient to generate very intuitive and easy-to-read API documents.
The comments we appear in the program can be divided into two types consciously, one is simple comments for ourselves to see, and the other is comments that comply with the javadoc specification, with the purpose of generating easy-to-read documents.
Read the generated API document carefully. There are three parts that need our explanation, as shown in the figure:

Introduction to javadoc specification

Introduction to javadoc specification

Introduction to javadoc specification

##The contents of the red box above are all comments I added. It is a simple Hello class. The source code is as follows. If you are interested, you can try it yourself:

/**
  *	@author XXXX
  *	@version 創(chuàng)建時間:2021年1月21日 下午3:22:01
  *	
  */
public class Hello {

	/**
	 * main()方法簡述(后面這個dot必不可少).
	 * <p>這就是為了測試注釋<br>
	 * 沒什么好說明的,只為了說明能出現(xiàn)在這里
	 * @param args 就是系統(tǒng)配的,沒啥說的
	 * 
	 */
	public static void main(String[] args) {
//		 TODO Auto-generated method stub
		System.out.println("hello");	

	}
	
	/**
	 * havaReturn方法就是為了測試javadoc注釋規(guī)范的.
	 * <p>我發(fā)現(xiàn)只有有返回值的方法才可以使用return標(biāo)簽<br>
	 * 沒有return硬是要用,只會在javadoc時候報錯
	 * @param a 輸入的第一個int類型的參數(shù)
	 * @param b 輸入的第二個int類型的參數(shù)
	 * @return add 兩個數(shù)的和運(yùn)算結(jié)果
	 */
	public int haveReturn(int a,int b){
		int add=0;
		add=a+b;
		return add;
	}

}

There are several points that need to be pointed out:

If you want the author and version to appear in the API document, you must not only add @author and @version in the program comments (it should be noted that annotating @author in multiple places in the program will only be displayed once in the final document. I recommend only comment once), and also point it out in the dos command when compiling:

javadoc -d folder -version -author Hello.java
where -d folder means you put the generated API document (actually many web pages (composed) in a folder folder. Of course, the folder can also be a path.

How to distinguish between method summary and method details?

/**
	 * main()方法簡述(后面這個dot必不可少).
	 * <p>這就是為了測試注釋<br>
	 * 沒什么好說明的,只為了說明能出現(xiàn)在這里
	 * @param args 就是系統(tǒng)配的,沒啥說的
	 * 
	 */
	public static void main(String[] args) {
//		 TODO Auto-generated method stub
		System.out.println("hello");	

	}
You must have found that there are a lot of comments about methods. How does javadoc extract the summary? That's right, just rely on one dot(.), observe the dot mentioned in my comment, that is the key to extract the summary. The dot is preceded by the summary, and everything is a detailed introduction (the detailed introduction includes the summary)

How to control the typesetting of comments in generated documents

What we can control in the program is the typesetting of comments, but this typesetting is not recognized by javadoc. Javadoc finds a line of comments and only removes * and spaces. , I just passed it over and noticed that the generated document is of HTML type, so as long as you comment the HTML syntax in the program, you can edit the API document format. Don't worry about it being too difficult, because we just use some simple HTML syntax, such as paragraphs.

, newline
these are enough, after all, the comments will not be very long.

@param parameter 1 description (note the format)

@return return value description (note the format)

If there is a return value, write it. If there is no return value, you don’t need to write it. If you write it, it will Error reporting

In fact, writing class comments and method comments is very simple. Just type /** in front of the class and method, and then press Enter, the system will automatically add it, and we can modify how the system adds it

How to modify the content that appears when creating a new file, how to make the automatically completed comments under our control (to be done)

We see this from the standard class file:

Introduction to javadoc specification

We all know that out is an attribute (field) of the System class, which is of type PrintStream. There are many methods defined in the PrintStream class. These are naturally out methods, so when defining out , there are a lot of @see in the comments in front of it. This is the best place to use @see annotation. We recommend that when defining the fields of a class, if the field is a composite type (especially a custom composite type), then Note @see in front, this has two advantages, please see the picture:

Introduction to javadoc specification

Introduction to javadoc specification

I believe you are familiar with these two pictures. The first one is a prompt that appears when the cursor stays when writing a program. If you write comments according to the javadoc specification, then you wrote it yourself. The program also appears with these extremely helpful prompts. The second is the detailed description of the out field in the String class in the Java8 API document. This is also the credit of @see. You wrote @see, and there is such annotation in your own project API document.

Related recommendations: java introductory tutorial

The above is the detailed content of Introduction to javadoc specification. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Variable naming conventions required in Python learning Variable naming conventions required in Python learning Jan 20, 2024 am 09:03 AM

Variable naming conventions you need to know when learning Python An important aspect when learning the Python programming language is learning how to name and use variables correctly. Variables are identifiers used to store and represent data. Good variable naming conventions not only improve the readability of your code, but also reduce the possibility of errors. This article will introduce some commonly used variable naming conventions and give corresponding code examples. Use Meaningful Names Variable names should have a clear meaning and be able to describe the data stored in the variable. Using meaningful names allows it to

How can you understand the design principles and goals behind the latest PHP code specification by reading its source code? How can you understand the design principles and goals behind the latest PHP code specification by reading its source code? Sep 05, 2023 pm 02:46 PM

How can you understand the design principles and goals behind the latest PHP code specification by reading its source code? Introduction: When writing high-quality PHP code, it is very important to follow certain coding standards. Through code specifications, the readability, maintainability and scalability of the code can be improved. For the PHP language, there is a widely adopted code specification, namely PSR (PHPStandardsRecommendations). This article will introduce how to read the source code of the latest PHP code specification

PyCharm formatting shortcut key analysis: how to quickly unify code style PyCharm formatting shortcut key analysis: how to quickly unify code style Jan 27, 2024 am 10:38 AM

Quickly standardize code style: The readability and consistency of PyCharm formatted shortcut key parsing code is very important for programmers. Under the premise of following certain coding style specifications, writing clean code can make the project easier to maintain and understand. As a powerful integrated development environment, PyCharm provides shortcut keys to help us quickly format code. This article will introduce several commonly used shortcut keys in PyCharm, as well as their specific usage and effects. 1. Code automatic indentation (Ctrl

What is the standard for API interface? What is the standard for API interface? Feb 23, 2024 pm 08:15 PM

API (Application Programming Interface) interface specification refers to a series of guidelines and specifications that define and specify API interfaces in software development. The purpose of the API interface specification is to ensure interoperability and consistency between different software components. This article will introduce several important aspects of API interface specifications. Interface naming convention The name of an API interface should be clear, concise, and consistent, and can accurately express its function and purpose. Naming conventions should follow industry practices and internal conventions of the development team, and avoid using vague and confusing terms. this

How to solve the problem of irregular use of indented spaces in Python code? How to solve the problem of irregular use of indented spaces in Python code? Jun 24, 2023 pm 09:03 PM

Python is a very popular programming language. It is favored by more and more people because of its simplicity, ease of understanding, and ease of learning. In Python, indentation and code format are very important. If used irregularly, it will greatly affect the readability and maintainability of the code. This article aims to introduce several methods to solve the problem of irregular indentation spaces in Python code. Using automated tools In Python programming, it is very important to adhere to coding standards. Each indentation in the code should use the same number of spaces. If you manually modify line by line

Common coding practices and norms in Go language Common coding practices and norms in Go language Jun 01, 2023 am 09:51 AM

With the gradual popularization and application of Go language, the coding practices and specifications of Go language have also received more and more attention and attention. This article will introduce common coding practices and specifications in the Go language to help developers write high-quality Go code. Code formatting Code formatting in Go language is a very important specification and practice. Go language provides an official code formatting tool - goimports, which can automatically adjust the indentation, spaces, quotation marks, etc. of the code, and can also automatically import unimported packages. Use goimpo

PHP writing standards and teamwork practice: improving project development efficiency PHP writing standards and teamwork practice: improving project development efficiency Aug 25, 2023 pm 11:27 PM

The practice of PHP writing specifications and team cooperation: improving project development efficiency In project development, writing specifications is a necessary practice. Good writing standards can improve the readability and maintainability of code, avoid low-level errors, and enable team members to collaborate better. This article will introduce some practices of writing specifications in PHP and explore how to apply these specifications in teamwork to improve project development efficiency. Using the PSR-2 standard PSR-2 is a standard for PHP code specifications. It establishes a set of code formats, comments,

Detailed explanation of docking examples between Go language and Tencent Cloud interface Detailed explanation of docking examples between Go language and Tencent Cloud interface Jul 06, 2023 pm 05:06 PM

Detailed example of docking between Go language and Tencent Cloud interface In recent years, with the development of cloud computing technology, cloud service providers have become the first choice of many enterprises and developers. As a leading cloud service provider in China, Tencent Cloud provides a series of API interfaces for developers to call in order to facilitate developers to use its rich cloud service functions. As a simple and efficient programming language, Go language is increasingly favored by developers. This article will introduce in detail how to use Go language to connect with Tencent Cloud interface, and give specific example code. 1. Early stage

See all articles