package test;
public class ClassTest extends test2{
public static int qq = 444;
@Override
public int print() {
return 333;
}
public static void main(String[] args) {
ClassTest classTest = new ClassTest();
System.out.println(classTest.qq);
System.out.println(classTest.print());
System.out.println(((test2)classTest).qq);
System.out.println(((test2)classTest).print());
}
}
class test2{
public static int qq = 111;
public int print(){
return 222;
}
}
[java] view plain copy
结果是:
[java] view plain copy
444
333
111
333
[java] view plain copy
这个地方值得我们去深思一下java对象执行的机制。
|
|