--Start with: /**
--End with: */
Special “tags” (@param; @result; etc;)
/**
*Sets the number of units earned (描述了这个方法的作用)
*@param units The number of units earned. (描述这个方法中的参数数, @param 后紧跟的units是参数名,这个参数units的意思就是,所得学分。)
*/
public void setUnits(double units){
unitsEarned = units
}
这不一定非常清晰,但只要你看过,便会记住和理解。但是计算机可以很好的理解,并创建很好的文献资料。
URL: jtf.acm.org/javadoc/studentjtf javadoc的学生版,可以看到所有ACM库的javadoc.当遇到问题时可以查阅。
所有的doc都是html的文档。比如RandomGenerator的javadoc。这是一个机遇注释和代码自动生成的。
/**
*解释了整个类的能力,比如,我们将要创建这个类,以追踪这个学生。我在乎的是什么呢?这是个很简单的形式。我关心的是他的名字、ID以及他所得学分。这些是所有我们关心的内容。书中的例子还包括了其他内容。
*/
public class Student{
/**
*构造函数是什么呢?我该如何创建学生呢?Stuent类并不是扩展而来的,所有的学生都只是对象而已,学生的构造函数设定了,(name,id),我们追踪的是学生的信息,被存储的实例变量。
*/
public Student(String name, int id){
studentName = name;
studentID = id;
}
/**
*Gets the name of this student.
*@return The name of the student.
*/
public String getName(){
return studentName;
}
/**
*Get the ID number of this student.
*@return The ID number of this student.
*/
public int getID(){
return studentID;
}
/**
*Sets the number of units earned.
*@param units The new number of units earned.
*/
public void setUnits(double units){
unitsEarned = units;
}
/**
*Gets the number of units earned
*@return The number of units the student has earned.
*/
public double getUnits(){
return unitsEarned;
}
}
转载于:https://blog.51cto.com/mazego/623344