My Code : A.java
package pack1;
public class A {
final static int x;
}
Command used to compile Code :
javac -d . A.java
Compile Time Error :
A.java:5: error: variable x not initialized **in the default constructor**
final static int x;
^
1 error
Now, here compiler should throw error like =>
error: variable x not initialized **in the static block**
Because here in this case possible place where you can initialize, the declared final static uninitialized variable are only => 1) at the time of declaration itself OR 2) inside static block
There is no constructor in the picture...still Compiler is throwing error which is misleading.
I am using jdk 1.8
java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)