Commenting the Public Interface
/**
A bank account has a balance that can be changed by
deposits and withdrawals.
*/
public class BankAccount
{
/**
Withdraws money from the bank account.
@param
the amount to withdraw
*/
public void withdraw(double amount)
{
//implementation filled in later
}
/**
Gets the current balance of the bank account.
@return
the current balance
*/
public double getBalance()
{
//implementation filled in later
}
}
Copy the above information to a file,
BankAccount.java,
in a new folder of your flash drive.
Run the javadoc utility from your command
prompt:
javadoc BankAccount.java
Go to your folder to click index.html to see results.
Provide documentation comments for
every class
every method
every parameter
every return value.
The javadoc utility formats your comments into a neat set of documents that you can view in a web browser.


Exercise: To create a web information by the following program.
/**
This class models a tally counter.
*/
public class Counter
{
private int value;
/**
Gets the current value of this counter.
@return the current value
*/
public int getValue()
{
return value;
}
/**
Advances the value of this counter by 1.
*/
public void count()
{
value = value + 1;
}
}