我有一个名为StaticTest
和StaticInherited extends StaticTest
的类,我想在StaticTest.A
类中使用StaticInherited
类,但是它说类型不兼容。
class StaticTest {
static class A{
int a = 10;
int getA(){
return a;
}
}
}
public class StaticInherited extends StaticTest{
static class A{
int a = 20;
}
public static void main(String[] args) {
StaticTest.A x = new StaticTest.A();
System.out.println(x.a);
StaticInherited.A y = new StaticInherited.A();
System.out.println(y.a);
StaticInherited.A z = new StaticTest.A();
System.out.println(z.a);
}
}