class Bowl {
Bowl(int er) {
System.out.println("Bowl(" + er + ")");
}
void f(int er) {
System.out.println("f(" + er + ")");
}
}class Table {
static Bowl b1 = new Bowl(1);
Table() {
System.out.println("Table()");
b2.f(1);
}
void f2(int er) {
System.out.println("f2(" + er + ")");
}
static Bowl b2 = new Bowl(2);
}class Cupboard {
Bowl b3 = new Bowl(3);
static Bowl b4 = new Bowl(4);
Cupboard() {
System.out.println("Cupboard()");
b4.f(2);
}
void f3(int er) {
System.out.println("f3(" + er + ")");
}
static Bowl b5 = new Bowl(5);
}public class StaticInitialization {
static Test monitor = new Test();
public static void main(String[] args) {
System.out.println("Creating new Cupboard() in main");
new Cupboard();
System.out.println("Creating new Cupboard() in main");
new Cupboard();
t2.f2(1);
t3.f3(1);
}
static Table t2 = new Table();
static Cupboard t3 = new Cupboard();
}
Bowl(1)
Bowl(2)
Table()
f(1)
Bowl(4)
Bowl(5)
Bowl(3)
Cupboard()
f(2)
Creating new Cupboard() in main
Bowl(3) ???????????
Cupboard()
f(2)
Creating new Cupboard() in main
Bowl(3) ????????????
Cupboard()
f(2)
f2(1)
f3(1)那两个带????的结果 Bowl(3)是怎么得出来的???
Bowl(int er) {
System.out.println("Bowl(" + er + ")");
}
void f(int er) {
System.out.println("f(" + er + ")");
}
}class Table {
static Bowl b1 = new Bowl(1);
Table() {
System.out.println("Table()");
b2.f(1);
}
void f2(int er) {
System.out.println("f2(" + er + ")");
}
static Bowl b2 = new Bowl(2);
}class Cupboard {
Bowl b3 = new Bowl(3);
static Bowl b4 = new Bowl(4);
Cupboard() {
System.out.println("Cupboard()");
b4.f(2);
}
void f3(int er) {
System.out.println("f3(" + er + ")");
}
static Bowl b5 = new Bowl(5);
}public class StaticInitialization {
static Test monitor = new Test();
public static void main(String[] args) {
System.out.println("Creating new Cupboard() in main");
new Cupboard();
System.out.println("Creating new Cupboard() in main");
new Cupboard();
t2.f2(1);
t3.f3(1);
}
static Table t2 = new Table();
static Cupboard t3 = new Cupboard();
}
Bowl(1)
Bowl(2)
Table()
f(1)
Bowl(4)
Bowl(5)
Bowl(3)
Cupboard()
f(2)
Creating new Cupboard() in main
Bowl(3) ???????????
Cupboard()
f(2)
Creating new Cupboard() in main
Bowl(3) ????????????
Cupboard()
f(2)
f2(1)
f3(1)那两个带????的结果 Bowl(3)是怎么得出来的???
解决方案 »
- 如何关闭?
- spring的xml出错了...
- 一个菜鸟的问题!
- 请教远程写文件的问题(并非指服务器自身)
- java 可以用来做图象识别么
- 我看书上的异常中的Catch语句里总是用System.exit(1),它与System.exit(0)有什么区别呀?
- 请问用什么样的方法能够在浏览器中调用Excel来显示从数据库读的数据,谢谢!
- 子类父类属于同一个类么
- 请问如何在oracle数据库中存取图片?
- apache做https代理服务器,可用浏览器上网,却不能用程序发送报文,求助大神啊,一周了都没搞定
- 从ResultSet取字段值的效率问题
- 请问利用jdbc如何得到所有的表(用户表)和这些表的所有列的名称
的时候会先Bowl b3 = new Bowl(3); ...