As for your first question, static blocks are actually processed in the order in which they appear, but declarations are processed first before static blocks. Declarations are processed as part of the class preparation ( JLS ยง12.3.2 ) that occurs before initialization ( JLS ยง12.4.2 ). For training purposes, the whole JLS ยง12 , as well as JLS ยง8 , in particular ยง8.6 and JLS ยง8.7, may be useful. (Thanks, Ted Hopp and irreputable for invoking these sections.)
There is not enough information in your cited code to answer the second question. (In any case, on SO, it is better to ask one question per question.) But, for example:
public class Foo { static { ture = 9; } static int ture; {
... only prints once :9: since only one instance was created. It does not display it at all if you delete the line new Foo(); . If you see :9: three times, then it looks like you are creating three instances of code that you did not show.
source share