db_pool * db_pool::inst = nullptr; //for a start
当我打印A时,结果:
public class Test {
public static final Object A = getB();
public static final Object B = "String B"; // Object
public static Object getB() {
return B;
}
}
我认为这是合理的。但是当我将B的类型更改为System.out.println(Test.A); // result : null
System.out.println(Test.B); // result : String B
System.out.println(Test.getB()); // result : String B
时,
String
发现A的值不为空!
public class Test {
public static final Object A = getB();
public static final String B = "String B"; //<----( Object -> String )
public static Object getB() {
return B;
}
}
为什么会有这样的区别?