Page 807 - Introduction to Programming with Java: A Problem Solving Approach
P. 807
Appendix 6 Javadoc 773
/*****************************************************************
* Student_jd.java
* Dean & Dean
*****************************************************************/
import java.util.Scanner;
single-line javadoc comment
/** This class handles processing of a student's name. */
public class Student_jd
{
private String first = ""; // student's first name
private String last = ""; // student's last name
//**************************************************************
public Student_jd()
{}
/**
multiple-line javadoc comment
This constructor verifies that each passed-in name starts with
an uppercase letter and follows with lowercase letters.
*/
Apago PDF Enhancer
public Student_jd(String first, String last)
{
}
setFirst(first);
setLast(last);
Figure A6.2 Top part of Figure A5.1’s Student class, modified to accommodate javadoc
With these changes implemented in the Student.java code, Figure A6.3 shows the top part of what javadoc generates. If you compare this with Figure A6.1, you’ll see that Figure A6.3 includes the general comment for the whole class and the special comment for the two-parameter constructor. We also changed therestofthecodesothatStudent_jdhas/** ... */javadocblockcommentsabovethemethod headings too. Therefore, the javadoc output also includes special comments for each method. The con- structor and method comments also appear in the “Detail” parts of the output display, which is below what you see in Figures A6.1 and A6.3.
Within a /** ... */ javadoc comment block, javadoc also recognizes several special tags, which enable it to extract other kinds of information. For a complete description, see:
http://java.sun.com/j2se/javadoc/
Figure A6.4 contains an abbreviated list of javadoc tags.
The most important tags are the @param and the @return tags. Figure A6.5 shows a class originally
defined in Figure 13.11 but with its comments modified for javadoc. The functionality of this class is