Java Reference
In-Depth Information
public knowledge. In Java, a specification that lists the class methods can be
generated from the implementation by using
javadoc
.
Information-hiding can be enforced by using the
private
keyword. Initial-
ization of objects is controlled by the constructors, and the components of the
object can be examined and changed by accessor and mutator methods,
respectively. Figure 3.17 illustrates many of these concepts, as applied to a
simplified version of
ArrayList
. This class,
StringArrayList
, supports
add
,
get
,
and
size
. A more complete version that includes
set
,
remove
, and
clear
is in
the online code.
The features discussed in this chapter implement the fundamental aspects
of object-based programming. The next chapter discusses inheritance, which
is central to object-oriented programming.
accessor
A method that examines an object but does not change its state. (76)
aliasing
A special case that occurs when the same object appears in more than
one role. (81)
atomic unit
In reference to an object, its parts cannot be dissected by the gen-
eral users of the object. (70)
class
Consists of fields and methods that are applied to instances of the class.
(71)
class specification
Describes the functionality, but not the implementation. (73)
CLASSPATH
variable
Specifies directories and files that should be searched to
find classes. (94)
composite pattern
The pattern in which we store two or more objects in one
entity. (96)
constructor
Tells how an object is declared and initialized. The default con-
structor is a member-by-member default initialization, with primitive
fields initialized to zero and reference fields initialized to
null
. (76)
design pattern
Describes a problem that occurs over and over in software
engineering, and then describes the solution in a sufficiently generic man-
ner as to be applicable in a wide variety of contexts. (96)
encapsulation
The grouping of data and the operations that apply to them to
form an aggregate while hiding the implementation of the aggregate.
(70)
equals
method
Can be implemented to test if two objects represent the same
value. The formal parameter is always of type
Object
. (78)
field
A class member that stores data. (72)
Search WWH ::
Custom Search