When I print the constant in main, the static block does not execute, but when I print stat, it does execute. Is there any importance to static final in Java?
package com.test.doubt;
class Doubt {
public static final int constant = 123;
public static int stat = 123;
static {
System.out.println("Static Block");
}
}
public class MyProgram {
public static void main(String[] args) {
System.out.println(Doubt.constant);
}
}