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:
/** * @author XXXX * @version 创建时间:2021年1月21日 下午3:22:01 * */ public class Hello { /** * main()方法简述(后面这个dot必不可少). * <p>这就是为了测试注释<br> * 没什么好说明的,只为了说明能出现在这里 * @param args 就是系统配的,没啥说的 * */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("hello"); } /** * havaReturn方法就是为了测试javadoc注释规范的. * <p>我发现只有有返回值的方法才可以使用return标签<br> * 没有return硬是要用,只会在javadoc时候报错 * @param a 输入的第一个int类型的参数 * @param b 输入的第二个int类型的参数 * @return add 两个数的和运算结果 */ 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.
/** * main()方法简述(后面这个dot必不可少). * <p>这就是为了测试注释<br> * 没什么好说明的,只为了说明能出现在这里 * @param args 就是系统配的,没啥说的 * */ 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.
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
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!

学习Python时需要了解的变量命名规范在学习Python编程语言时,一个重要的方面是学习如何正确命名和使用变量。变量是用来存储和表示数据的标识符。良好的变量命名规范不仅能提高代码的可读性,还能减少出错的可能性。本文将介绍一些常用的变量命名规范,并给出相应的代码示例。使用有意义的名字变量名应该具有清晰的含义,能够描述变量所存储的数据。使用有意义的名字可以让其

如何通过阅读最新PHP代码规范的源代码来理解其背后的设计原则和目标?引言:在编写高质量的PHP代码时,遵循一定的代码规范是非常重要的。通过代码规范,可以提高代码的可读性、可维护性和可扩展性。而对于PHP语言来说,有一份被广泛采用的代码规范,即PSR(PHPStandardsRecommendations)。本文将介绍如何通过阅读最新PHP代码规范的源代码

快速规范代码风格:PyCharm格式化快捷键解析代码的可读性和一致性对于程序员来说非常重要。在遵循一定的代码风格规范的前提下,编写整洁的代码可以使得项目更易于维护和理解。而PyCharm作为一款功能强大的集成开发环境,提供了快捷键来帮助我们快速格式化代码。本文将介绍几个PyCharm中常用的快捷键,以及它们的具体使用方法和效果。1.代码自动缩进(Ctrl

Python是一门非常流行的编程语言,因其简洁易懂,易于学习等特点,得到了越来越多人的青睐。在Python中,缩进和代码的格式是十分重要的,若使用不规范,会极大影响代码的可读性和可维护性。本文旨在介绍几种解决Python代码中缩进空格不规范的方法。采用自动化工具在Python编程中,遵守代码规范十分重要,代码中每个缩进应该用相同数量的空格。如果手动一行行修改

PHP编写规范与团队合作的实践:提升项目开发效率在项目开发中,编写规范是一种必要的实践。良好的编写规范可以提高代码的可读性、可维护性,避免出现低级错误,使团队成员能够更好地协同合作。本文将介绍一些PHP编写规范的实践,并探讨如何在团队合作中应用这些规范,以提升项目的开发效率。使用PSR-2标准PSR-2是PHP代码规范的一个标准,建立了一套在代码格式、注释、

C++是一种强大的编程语言,广泛应用于系统级开发、游戏开发和高性能计算等领域。然而,C++也因其复杂性和灵活性而需要更高的代码质量和性能。本文将探讨一些关于如何提高C++代码质量和性能的建议。了解内存管理:C++是一种底层语言,能够直接操作内存。因此,了解如何正确地进行内存管理是至关重要的。避免内存泄漏和悬空指针是必须的。使用智能指针和RAII(资源获取即初

Python是一种高度灵活且易学易用的编程语言,大量的第三方库与模块使得Python具备了强大的功能。但是由于库的多样性和灵活性,对于Python开发者而言时常会出现库使用不规范的错误。正确处理这些错误可以提高代码的质量,增加代码可读性,避免程序错误和漏洞的生成。本文将介绍如何解决Python的代码中库使用不规范的错误。缺乏库的声明在Python中,如果要

随着Go语言的逐渐普及和应用,Go语言的编码实践和规范也越来越受到关注和重视。本文将介绍Go语言中的常见编码实践和规范,以帮助开发者写出高质量的Go代码。代码格式化Go语言中的代码格式化是一种非常重要的规范和实践。Go语言提供了一个官方的代码格式化工具——goimports,可以自动调整代码的缩进、空格、引号等,并且还可以自动导入未导入的包。使用goimpo


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
