Page 328 - Introduction to Programming with Java: A Problem Solving Approach
P. 328
294
Chapter 7 Object-Oriented Programming—Additional Details
18.
19.
For the component in question, you declare an instance reference variable for the container or other component you want it to know about. Then when you instantiate the component in question, you pass its constructor a reference to the container or other component, and you have its constructor initialize the corresponding instance reference variable.
In your definition of the container class, you declare an instance reference variable for each prospective component. In the container constructor you instantiate each component and assign a reference to it to the corresponding instance reference variable.
Apago PDF Enhancer