package ssh; public class father { public father() { System.out.println("father!"); } { System.out.println("father default!"); } static { System.out.println("father static!"); } } package ssh; public class son extends father{ public son(){ System.out.println("son!"); } { System.out.println("son default!"); } static { System.out.println("son static!"); } public static void main(String[] agrs) { System.out.println("start!"); new son(); System.out.println("middle!"); new son(); System.out.println("end!"); } }
结果:
father static!
son static!
start!
father default!
father!
son default!
son!
middle!
father default!
father!
son default!
son!
end!
时间: 2024-12-19 10:02:26