public class TestA  
{ 
        int n=0; 
        int m=0; 
} 
public class TestB extends TestA  
{ 
        int n=0; 
} 
public class E  
{ 
        TestA testA;         
        public void Out(TestA testA) 
        { 
                System.out.println("n:"+testA.n); 
                System.out.println("m:"+testA.m); 
        } 
 
} 
public class TestE extends E  
{ 
        public static void main(String[] args)  
        { 
                TestE e= new TestE(); 
                TestB testB =new TestB(); 
                testB.m =128; 
                testB.n =128; 
                e.Out(testB); 
        } 
} 
输出结果 
n:0 
m:128 
 
经调试这个n值的输出是TestA的值,为什么不是TestB的值呢? 
求大神帮忙解答,我是在什么地方理解错了! 
 
 |   
        
 
    
    
    
     
 
 |