本帖最后由 钟翠翠 于 2014-6-23 22:46 编辑
为什么System.out.println(z.num); 输出的结果还是5
package practice;
class Fu
{
int num=5;
}
class Zi extends Fu
{
int num=8;
}
public class DuoTaiDemo3 {
public static void main(String[] args)
{
Fu f=new Zi();
System.out.println(f.num);
Zi z=(Zi)f;
System.out.println(z.num);
}
}
|
|