
1
Chapter 2. Programming
Basics
ITSS Java Programming
CAO Tuan-Dung, HUT

2
Comments
Explanation to improve readability of program
// comments -- one line
int nquest; // number of questions.
/* ... */ comments -- multiple lines
javadoc comments
Comments that in form of /** …*/ are used by the javadoc program to
produce HTML documentation for the program
Example:
/** This is an example of special java doc comments used for \n
generating an html documentation. It uses tags like:
@author Florence Balagtas
@version 1.2
*/

3
Javadoc
Tool that pulls out the class and the method etc.,
defined in the source file, and creates the reference
manual of the program
Main tag of ‘javadoc’
@see Reference destination name : Make the reference
link of other classes and related packages from the class
of the object .
@exception Explanation of exception class name:
Describe the explanation of the exception that the method
of object has possibility to throw.
@param Explanation of argument name
@return The explanation of the return value of the
method of the object is described.

4
Hand on Lab: Javadoc
Use your text editor or Eclipse to create a
java program named: Circle.java
The content of this file will be shown in next
slides
javadoc –private Circle.java
javadoc -author -version Circle.java

5
Circle.java
import java.awt.*;
import java.applet.*;
/**
* A simple circle class.
*
* @author Samuel A. Rebelsky
* @version 1.1 of February 1999
*/
public class Circle {
/** The current color of the circle. */
protected Color color;
/** The current diameter of the circle. */
protected int diameter;
/**
* Create a new circle with specified
diameter and color.
*/
public Circle(int diameter, Color color) {
this.diameter = diameter;
this.setColor(color);
} // Circle(int, Color)
/**
* Create a new circle with specified
diameter and default color.
*/
public Circle(int diameter) {
this.diameter = diameter;
this.setColor(Color.blue); // Blue is as
good a default as any.
} // Circle(int)