Java Reference
In-Depth Information
/**
* Computes and returns the distance between this point
* and the given other point.
*
* @param p the point to which the distance is computed
* @return the distance, computed as the square root of
* the sums of the squares of the differences
* between the two points ' x-coordinates (dx)
* and between their y-coordinates (dy)
* @throws NullPointerException if p is null
*/
public double distance(Point p) {
int dx = x p.x;
int dy = y p.y;
return Math.sqrt(dx * dx + dy * dy);
}
As we mentioned previously, Javadoc comments can be converted into web docu-
mentation pages. Some Java editing environments include this functionality; check
your editor to see whether it is provided. If not, Sun's JDK includes a command-line
tool for generating the pages. To use it, open a terminal window to the directory of
your source code files and type the following command:
javadoc *.java
The web page that is generated for the preceding Point class is shown in Figure C.2.
Figure C.2
Generated Javadoc pages for Point class
 
Search WWH ::




Custom Search