I am learning Java and writing simple code below:
public class Test { private int a = b; private final static int b = 10; public int getA() { return a; } } public class Hello { public static void main(String[] args) { Test test = new Test(); System.out.println(test.getA()); } }
Result: 10 . Well done! It works successfully and has no error.
Can someone explain why I can assign a static variable before declaring it?
source share