1. 综述
java 的文档注释功能: 在编写java源文件时候,使用
/**
@author: 指定Java程序的作者
@version: 指定源文件的版本
@param: 方法参数的说明信息
@return: 方法的返回值说明信息
@exception: 抛出异常的类型
@throws: 抛出的异常, 与@exception同义
*/
定义注释,就可以使用JDK提供的javadoc工具直接将源代码里的文档注释提取成一份系统的API文档。
2. 代码举例如下:
-
package com.std.crazy.dtnum;
-
/**
-
*
-
* @author david
-
* <br/>website: <a href="http://www.***.org">crazy Java bind</>
-
* <br/>Copyright (C),2001-2012,
-
* <br/>This programs is protected by copyright david
-
* @version 1.0
-
*/
-
public class Student {
-
-
/**
-
* the name attribute
-
*/
-
public String name;
-
/**
-
* the protected attribute of age
-
*/
-
protected int age;
-
public String getName() {
-
return name;
-
}
-
/**
-
* set the name of student
-
* @param name the pointed name
-
*/
-
public void setName(String name) {
-
this.name = name;
-
}
-
/**
-
* get the age of student
-
* @return the age of this student
-
*/
-
public int getAge() {
-
return age;
-
}
-
public void setAge(int age) {
-
this.age = age;
-
}
-
}
3. 运行javadoc命令如下
切换到java 源文件所在目录 cd F:\kq\java_ecli_workspaces\workspaces\Bach\Crazy_Java\src\com\std\crazy\dtnum
dir
2016-09-11 09:43 757 Student.java
javadoc -d F:\快钱\java_ecli_workspaces\apidoc -windowtitle 学生管理系统 javadoc 学生管理API文档 -header 我的类 -version -author
4. 运行结果
会生成一组html文件,
生成的API到此结束,下一篇将会掩饰对多个包生成API文档。
我们在开发中多使用/** */的注释,可以自动生成api-doc文件,那么可以很好的进程程序的开发对接。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/674865/viewspace-2124795/
,如需转载,请注明出处,否则将追究法律责任。