I have been running this scenario in my head for a while. In the
surface it seems fine, but I keep thinking that somehow it will cause
problems.
class A {
}
class B extends A {
}
class C extends A {
B myB;
}
Class B is a A
Class C is also a A but also has a B which is in turn a A.
Is there anything wrong with having a variable in a class of a type
that inherits from the same parent that the class itself inherits from?
Thanks.
Mike Schilling - 19 Feb 2006 21:45 GMT
>I have been running this scenario in my head for a while. In the
> surface it seems fine, but I keep thinking that somehow it will cause
[quoted text clipped - 16 lines]
> Is there anything wrong with having a variable in a class of a type
> that inherits from the same parent that the class itself inherits from?
Not at all. Consider that A might be "java.lang.Object".
Jeffrey Schwab - 20 Feb 2006 14:26 GMT
>>I have been running this scenario in my head for a while. In the
>>surface it seems fine, but I keep thinking that somehow it will cause
[quoted text clipped - 18 lines]
>
> Not at all. Consider that A might be "java.lang.Object".
Nicely put!
jstorta - 20 Feb 2006 20:42 GMT
It makes perfect sense when you put it that way.
Thanks.