Stefan Farestam wrote:
>
> Suppose that I create a class A that is a subclass of a Java class.
> How can I convert instances of the baseclass to instances of the
> subclass?
Usually, the desire to convert instances of a base class into instances of a subclass indicates a design flaw.
That said, when it is needed, you create a constructor of the subclass that takes the base class instance and constructs a new instance that either wraps the base class instance or copies its data (a copy constructor).
kb
|