一个关于java类继承的典型问题。。。有兴趣的请进来
源代码是这样的:
class a{
int i=1;
int f(){
return(i);
}
}
class b extends a{
int i=12;
int f(){
return(i);
}
}
class testxx{
static void qq(){
a xx=new b();
System.out.println(xx.i);
System.out.println(xx.f());
}
}
public class testx{
public static void main(String[] args){
testxx.qq();
}
}
输出是:
1
12
这是为什么?