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
你适合学Java吗?4大专业测评方法
代码逻辑 吸收能力 技术学习能力 综合素质
先测评确定适合在学习