Java Reference
In-Depth Information
Objects are entities in your program that you manipulate by calling methods.
You manipulate an object by calling one or more of i
ts methods. A method consists of
a sequence of instructions that accesses the interna
l data. When you call the method,
you do not know exactly what those instructions are, but you do know the purpose of
the method.
37
38
Figure 3
Representation of the
System.out
Object
A method is a sequence of instructions that accesses the data of an object.
For example, you saw in
Chapter 1
that
System.out
refers to an object. You
manipulate it by calling the
println
method. When the
println
method is called,
some activities occur inside the object, and the ultimate effect is that text appears in
the console window. You don't know how that happens, and that's OK. What matters is
that the method carries out the work that you requested.
Figure 3
shows a representation of the
System.out
object. The internal data is
symbolized by a sequence of zeroes and ones. Think of each method (symbolized by
the gears) as a piece of machinery that carries out its assigned task.
In
Chapter 1
, you encountered two objects:
ȗ
System.out
ȗ
ÐHello, World!Ñ