w****r 发帖数: 2 | 1 Object is the base class in Java, each class in Java will inherit
Object even if you don't use 'extends Object', it's to say:
class A {...}
equals
class A extends Object{...}
you can get the assignment as you want,
class A {...}
class ChildClass extends A {...}
...
A varParent = ...;
ChildClass varChild = (ChildClass) varParent;
But pls note: the runtime type of varParent must be
ChildClass or ChildClass' subclass. otherwise you will
get runtime assignment exception. |
|