Java Reference
In-Depth Information
Note that the following is not a good definition because it could lead to a privacy leak:
public void
set(String newName, Date birthDate, Date deathDate)
{
//Not good
name = newName;
born = birthDate;
died = deathDate;
}
42. The class
String
is an immutable class. The classes
Date
and
Person
are mutable
classes.
43. The class
String
is an immutable class.
44. To make the class available to your program, you need to insert the following at
the start of the file containing your class:
import
mypackages.library1.CoolClass;
To make all the classes in the package available to your program, insert the follow-
ing instead:
import
mypackages.library1.*;
45. To make a class a member of the package named
mypackages.library1
, you
must insert the following at the start of the file with the class definition and place
the file in the directory corresponding to the package (as described in the text):
package
mypackages.library1;
(Only the
.class
file is required to be in the directory corresponding to the pack-
age, but it may be cleaner and easier to place both the
.java
file and the
.class
file there.)
46. A package name must be a path name for the directory that contains the classes
in the package, but the package name uses dots in place of \ or / (whichever your
operating system uses). When naming the package, you use a relative path name
that starts from any directory named in the value of the CLASSPATH (environ-
ment) variable.
47.
javadoc
never extracts the body of a method definition, nor (when run in default
mode) does
javadoc
ever extract anything marked
private
in a class definition.
48. When run in default mode,
javadoc
extracts only comments that satisfy the
following two conditions:
1. The comment must immediately precede a public class definition, a public
method definition, or other public item.
2.
The comment must use the
/*
and
*/
style, and the opening
/*
must contain
an extra
*
. So the comment must be marked by
/**
at the beginning and
*/
at
the end. In particular,
javadoc
does not extract any // style comments.