Question regarding the flow of execution with static blocks
posted 7 years ago
The block that increments x is not a static block but an initializer block. These blocks are run before the constructor in top-to-bottom order. So when you call "new CodeWalkTwo()" that calls this initializer block, incrementing x from 3 to 4. You then pre-increment x again when printing, leading to 5.