位置:广州粤嵌培训机构从化区校区嵌入式加java培训 > 学校动态 > Java文档注释

Java文档注释

来源:广州粤嵌培训机构从化区校区嵌入式加java培训时间:2022/5/12 19:09:40

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

领取试听课
每天限量名额,先到先得

尊重原创文章,转载请注明出处与链接:http://www.peixun360.com/6339/news/524049/违者必究! 以上就是广州粤嵌培训机构从化区校区嵌入式加java培训 小编为您整理 Java文档注释的全部内容。

温馨提示:提交留言后老师会第一时间与您联系!热线电话:400-0859-208