一个例子:
运行:
写道
javadoc -d . Attr.java -encoding utf-8
代码:
package P1;
/**
* An <code>Attr</code> object defines an attribute as a
* name/value pair, where the name is a <code>String</code>
* and the value an arbitrary <code>Object</code>.
*
* @version 1.1
* @author Alan
* @since 1.0
*/
public class Attr {
/** The attribute name. */
private final String name;
/** The attribute value. */
private Object value = null;
/**
* Creates a new attribute with the given name and an
* initial value of <code>null</code>.
* @see Attr#Attr(String,Object)
*/
public Attr(String name) {
this.name = name;
}
/**
* Creates a new attribute with the given name and
* initial value.
* @see Attr#Attr(String)
*/
public Attr(String name, Object value) {
this.name = name;
this.value = value;
}
/** Returns this attribute's value. */
public Object getValue() {
return value;
}
/**
* Sets the value of this attribute . Changes the
* value returned by calls to {@link #getValue()}.
* @param newValue The new value for the attribute.
* @return The original value.
* @see #getValue()
*/
public Object setValue(Object newValue) {
Object oldVal = value;
value = newValue;
return oldVal;
}
/**
* Returns a string of the form <code>name=value</code>.
*/
public String toString() {
return name + "='" + value + "'";
}
}
另外:eclipse中可以只用导出javadoc。
写道
使用eclipse生成文档(javadoc)主要有三种方法:
1,在项目列表中按右键,选择Export(导出),然后在Export(导出)对话框中选择java下的javadoc,提交到下一步。
在Javadoc Generation对话框中有两个地方要注意的:
javadoc command:应该选择jdk的bin/javadoc.exe
destination:为生成文档的保存路径,可自由选择。
按finish(完成)提交即可开始生成文档。
2,用菜单选择:File->Export(文件->导出),
剩下的步骤和第一种方法是一样的。
3,选中要生成文档的项目,然后用菜单选择,
Project->Generate Javadoc直接进入Javadoc Generation对话框,剩余的步骤就和第一种方法在Javadoc Generation对话框开始是一样的。