class Window {
Window(int maker) {
System.out.println("Window(" + maker + ")");
}
}
class House {
Window window1 = new Window(1);
House() {
System.out.println("House()");
w3 = new Window(33);
}
Window window2 = new Window(2);
void f() {
System.out.println("f()");
}
Window w3 = new Window(3);
}
public class OrderOfInitialization {
public static void main(String[] args) {
House h = new House();
h.f();
}
}
Window(1) Window(2) Window(3) House() Window(33) f()
class Bowl {
Bowl(int maker) {
System.out.println("Bowl(" + maker + ")");
}
void f1(int maker) {
System.out.println("f1(" + maker + ")");
}
}
class Table {
static Bowl bowl1 = new Bowl(1);
Table() {
System.out.println("Table()");
bowl2.f1(1);
}
void f2(int maker) {
System.out.println("f2(" + maker + ")");
}
static Bowl bowl2 = new Bowl(2);
}
class Cupboard {
Bowl bowl3 = new Bowl(3);
static Bowl bowl4 = new Bowl(4);
Cupboard() {
System.out.println("CupBoard()");
bowl4.f1(2);
}
void f3(int maker) {
System.out.println("f3(" + maker + ")");
}
static Bowl bowl5 = new Bowl(5);
}
public class StaticInitialization {
public static void main(String[] args) {
System.out.println("created new Cupboard() in main");
new Cupboard();
System.out.println("created new Cupboard in main");
new Cupboard();
table.f2(1);
cupboard.f3(1);
}
static Table table = new Table();
static Cupboard cupboard = new Cupboard();
}
Bowl(1) Bowl(2) Table() f1(1) Bowl(4) Bowl(5) Bowl(3) CupBoard() f1(2) created new Cupboard() in main Bowl(3) CupBoard() f1(2) created new Cupboard in main Bowl(3) CupBoard() f1(2) f2(1) f3(1)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有