I tried to understand the behavior of initialization order when static fields are initialized with a reference to the same enclosing class object.
public
Java Language specification is best source to understand all about initialization order. According to that in your scenario, static final field gets initialized before any class level variable gets initialized. When you remove the final, initialization was deferred. It should also be noted if you change
static Test t=new Test();
static int a=5;
to
static int a=5;
static Test t=new Test();
it will also print
a = 5
a = 5
because of initialization order.