相关疑难解决方法(0)

Java Legal Forward Referencing

以下代码是合法前向引用的情况吗?如果是,为什么?

public class MyClass
{
  private static int x = getValue();
  private static int y = 5;
  private static int getValue()
  {
    return y;
  }
  public static void main(String[] args)
  {
    System.out.println(x);
  }
}
Run Code Online (Sandbox Code Playgroud)

java reference forward static-initialization

12
推荐指数
2
解决办法
1314
查看次数

标签 统计

forward ×1

java ×1

reference ×1

static-initialization ×1