Java Reference
In-Depth Information
*/
public static void main (String[] args) {
BigInteger[] someValues = {BigInteger.TEN,
BigInteger.ONE};
System.out.println(addNumbers(someValues));
}
}
Comments can be added to the beginning of classes and fields in the same way. The
comments are helpful to you and other programmers maintaining the code, and their
specific format enables easy generation of an HTML reference to your code.
Generate the HTML reference by invoking the tool named Javadoc . This is a
command-line tool that parses a named Java source file and formulates HTML docu-
mentation based upon the defined class elements and Javadoc comments. For example:
javadoc JavadocExample.java
This command will produce several HTML files containing the documentation for
the class, methods, and fields. If no Javadoc comments exist within the source, some
default documentation will still be produced. To view the documentation, load the fol-
lowing file into your browser:
index.html
The file will be in the same directory as the class or package that you are docu-
menting. There will also be an index-all.html file giving a strict alphabetical list-
ing of documented entities.
Keep in mind that the same rules apply when using the Javadoc tool as when us-
ing javac . You must reside within the same directory as the source file, or prepend
the name of the file with the path to where the file is located.
How It Works
Generating documentation for applications from scratch can be quite tedious. Maintain-
ing documentation can be even more troublesome. The JDK comes packaged with an
extensive system for documentation known as Javadoc . Placing some special com-
ments throughout your code source and running a simple command-line tool makes it
easy to generate useful documentation and keep it current. Moreover, even if some of
Search WWH ::




Custom Search