<分区>
我今天在我们的代码中遇到了这个错误,花了一段时间才弄清楚。我发现它很有趣,所以我决定分享它。这是问题的简化版本:
public class Test {
static
{
text = "Hello";
}
public static String getTest() {
return text + " World";
}
private static String text = null;
}
猜猜 Test.getTest();
返回什么以及为什么?