java静态变量初始话的问题来源于<Thinking in java>源码?有人知道为什么报错吗?希望详细解答

来源:百度知道 编辑:UC知道 时间:2024/07/05 07:32:52
class Bow1{
Bowl(int marker){
System.out.println("Bowl("+marker+")");
}
void f(int marker){
System.out.println("f("+marker+")");
}
}
class Table{
static Bow1 b1=new Bow1(1);
Table(){
System.out.println("Table()");
}
void f2(int marker){
System.out.println("f2("+marker+")");
}
static Bow1 b2 = new Bow1(2);
}
class Cupboard{
Bowl b3 = new Bowl(3);
static Bowl b4 = new Bow1(4);
Cupboard(){
System.out.println("Cupboard()");
}
void f3(int marker){
System.out.println("f3("+marker+")");
}
static Bowl b5 = new Bowl(5);
}
public class StaticInitialization{
public static void main (String[] args){
System.out.println("Creating new Cupboard() in main");
new Cupboard();
System.out.println("

/**
* @author 作者:***
* @version 创建时间:2008-5-1 下午06:31:58
* 功能说明:
* @version 修改时间:2008-5-1
* 修改原因:
*/
class Bow1{ //************修改
Bow1(int marker){
System.out.println("Bowl("+marker+")");
}
void f(int marker){
System.out.println("f("+marker+")");
}
}
class Table{
static Bow1 b1=new Bow1(1);
Table(){
System.out.println("Table()");
}
void f2(int marker){
System.out.println("f2("+marker+")");
}
static Bow1 b2 = new Bow1(2);
}
class Cupboard{
Bow1 b3 = new Bow1(3); //************修改
static Bow1 b4 = new Bow1(4); //************修改
Cupboard(){
System.out.println("Cupboard()");
}
void f3(int marker){
System.out.println("f3("+marker+")");
}
static Bow1 b5 = new Bow1(5); //*