1-1-4-20 java语法问题一
发信人: smartcat007 (tomcat), 信区: Java标题: Re: java语法问题一
发信站: BBS 水木清华站 (Mon Jul 23 13:41:09 2001)
【 在 flystar (每日好心情) 的大作中提到: 】
: Class_A x = new Class_A();
: Class_B y;
: y = (Class_B)x;
: 这里的类转换中,是不是一定要求Class_A中含有Class_B中的所有变量和方法?
at compile time, Class_B and Class_A must have some relation(inheritance)
at run time,if the object referenced by x is not a subclass of Class_B
an exception will be thrown
: 就是说转换过去意味着损失,如果Class_A中没有包括Class_B中的所有变量和方法
: 那转换是怎么进行的?
this will not be possible at runtime
页:
[1]