专注Java教育14年 全国咨询/投诉热线:400-8080-105
动力节点LOGO图
始于2009,口口相传的Java黄埔军校
首页 学习攻略 Java学习 Java文档注释

Java文档注释

更新时间:2022-05-12 10:38:34 来源:动力节点 浏览779次

Java 代码中的大多数普通注释都解释了该代码的实现细节。相反,Java 语言规范定义了一种特殊类型的注释,称为文档注释,用于记录代码的 API。

文档注释是一个普通的多行注释,以/**(而不是通常的/*)开头并以*/结尾. 文档注释出现在类、接口、方法或字段定义之前,并包含该类、接口、方法或字段的文档。文档可以包括简单的 HTML 格式标记和其他提供附加信息的特殊关键字。文档注释会被编译器忽略,但它们可以被javadoc 程序提取并自动转换为在线 HTML 文档。这是一个包含适当文档注释的示例类: docstore.mik.ua/orelly/java-ent/jnut/ch07_03.htm

/** 
* This immutable class represents complex 
* numbers. * 
* @author David Flanagan 
* @version 1.0 
*/ 
public class Complex { 
/** 
* Holds the real part of this complex number. 
* @see #y 
*/ 
protected double x; 
/** 
* Holds the imaginary part of this complex number. 
* @see #x 
*/ 
protected double y; 
/** 
* Creates a new Complex object that represents the complex number 
* x+yi. 
* @param x The real part of the complex number. 
* @param y The imaginary part of the complex number. 
*/ public Complex(double x, double y) { this.x = x; this.y = y; } 
/** 
* Adds two Complex objects and produces a third object that represents 
* their sum. 
* @param c1 A Complex object 
* @param c2 Another Complex object 
* @return A new Complex object that represents the sum of 
* c1 and 
* c2. 
* @exception java.lang.NullPointerException 
* If either argument is null. 
*/ public Complex add(Complex c1, Complex c2) { return new Complex(c1.x + c2.x, c1.y + c2.y); } } docstore.mik.ua/orelly/java-ent/jnut/ch07_03.htm

 

提交申请后,顾问老师会电话与您沟通安排学习

免费课程推荐 >>
技术文档推荐 >>