Java instance variables initialization with method
问题 I am a little bit confused about the following piece of code: public class Test{ int x = giveH(); int h = 29; public int giveH(){ return h; } public static void main(String args[]) { Test t = new Test(); System.out.print(t.x + " "); System.out.print(t.h); } } The output here is 0 29 , but I thought that this has to be a compiler error, because the variable h should have not been initialized when it comes to the method giveH() . So, does the compilation go through the lines from top to bottom?