имеем код
class Test{
public static int x = 1;
static {
System.out.println("static");
}
}
public class Solution {
public static void main(String[] args) {
System.out.println(Test.x);
}
}
как и ожидается вывод
static
1
но если добавить к полю final
public static final int x = 1;
статик блок не отработает, и выведет 1
.
с чем это связано?