Components of Java Technology
Detailed description:
|
"Now in this example, we show a doughnut. The doughnut shows a Point object,
and inside the center is an x and a y value. Most often, data or values
(instance variables) are located in the center of the doughnut. And on
the outside are the functions (methods). In this case, we have a method
called distanceFrom at the bottom of the doughnut. Think of this doughnut
as jelly filled, rather than one with a hole. You really don't know what's
inside until you bite into it and taste the jelly. In the same manner,
think about the things in the center, the x and the y, as being encapsulated
in the object (or hidden or isolated) so that the only way to get to the
information in the center is through the outside. That's a basic principle
of object-oriented programming."
|
|