子类如何影响原始对象的所有实例?

时间:2014-05-30 00:29:32

标签: java object runtime decorator compile-time

我试图从wiki学习The decorator pattern is an alternative to subclassing. Subclassing adds behavior at compile time, and the change affects all instances of the original class; decorating can provide new behavior at run-time for individual objects.

来学习装饰模式

我有这个疑问,如果我创建一个类Original original = new Original();那么如何将它子类化为SubClass extends Original会影响类Original的对象的原始引用,它应该保持原样吗?

0 个答案:

没有答案