public class ClassT { public static void main(String[] args) { Father f = new Son(); System.out.println(f.x); } } class Son extends Father { int x = 30; public Son() { this.print(); x = 40; } public void print() { System.out.println("Son.x = " + x); } } class Father { int x = 10; public Father() { this.print(); x = 20; } public void print() { System.out.println("Father.x = " + x); } }


原文地址: https://www.cveoy.top/t/topic/pF1D 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录