Final variable in java : <pre><code> class Test {
     public static final int x;
     public static void main (String[] args) {
         Test.x = 42;
     }
 }
</code></pre>

<p>I have declared a static final variable, and when i compiled it the following error shown up.</p>

<pre><code> error: cannot assign a value to final variable x
 Test.x = 42;    
</code></pre>

<p>i think i have reached to the solution but i want to check if i am right or not?</p>

<p>I know that a static variable if not initialized is provided a default value. As it is a static final int variable it will be assigned a value of 0. later on, i tried to change the value to 42 which is not possible because the variable is final and cannot be changed from 0.</p>

<p>am i right or is there some other answer to it?</p>
