Java Reference
In-Depth Information
S ELF C HECK
5. Suppose we enhance the BankAccount class so that each account has
an account number. Supply a documentation comment for the constructor
public BankAccount(int accountNumber, double
initialBalance)
6. Why is the following documentation comment questionable?
/**
Each account has an account number.
@return the account number of this account
*/
public int getAccountNumber()
92
93
P RODUCTIVITY H INT 3.1: The javadoc Utility
Always insert documentation comments in your code, whether or not you use
javadoc to produce HTML documentation. Most people find the HTML
documentation convenient, so it is worth learning how to run javadoc . Some
programming environments (such as BlueJ) can execute javadoc for you.
Alternatively, you can invoke the javadoc utility from a command shell, by
issuing the command
javadoc MyClass.java
or, if you want to document multiple Java files,
javadoc *.java
The javadoc utility produces files such as MyClass.html in HTML format,
which you can inspect in a browser. If you know HTML (see Appendix H), you
can embed HTML tags into the comments to specify fonts or add images. Perhaps
most importantly, javadoc automatically provides hyperlinks to other classes
and methods.
You can run javadoc before implementing any methods. Just leave all the
method bodies empty. Don't run the compilerȌit would complain about missing
Search WWH ::




Custom Search