记录下来,以便以后查看
thinking in java 4th
chapter one
resuing the implementation
[b]The simplest way to reuse a class is to just use an object of that class directly, but you can also place an object of that class inside a new class. We call this “creating a member object.” Your new class can be made up of any number and type of other objects, in any combination that you need to achieve the functionality desired in your new class. Because you are composing a new class from existing classes, this concept is called [color=red]composition[/color] (if the composition happens dynamically, it’s usually called [color=red]aggregation[/color]). Composition is often referred to as a “has-a” relationship, as in “A car has an engine.”[/b]
thinking in java 4th
chapter one
resuing the implementation
[b]The simplest way to reuse a class is to just use an object of that class directly, but you can also place an object of that class inside a new class. We call this “creating a member object.” Your new class can be made up of any number and type of other objects, in any combination that you need to achieve the functionality desired in your new class. Because you are composing a new class from existing classes, this concept is called [color=red]composition[/color] (if the composition happens dynamically, it’s usually called [color=red]aggregation[/color]). Composition is often referred to as a “has-a” relationship, as in “A car has an engine.”[/b]