I understand that the following code is allowed (I've read the previous posts on the topic), but can someone explain to me what is actually happening when this class is run? Is the block skipped and then "i" is initialized at LINE 7, and then the block is run (setting "i" to 3) and then LINE 7 is run setting "i" to 2?
public class TestClass {
{
i = 3;
}
int i = 2; //LINE 7
}
If we look at the bytecode for the class:
We see that the code is run in the same order it appears in the source code, so first
iis set to 3, theniis set to 2.