final array in Java
<p>The following code in Java uses a <code>final</code> array of <code>String</code> and there is no question about it.</p>

<pre><code>package javaarray;

final public class Main
{
    public static final String[] CONSTANT_ARRAY={"I", "can", "never", "change"};

    public static void main(String[] args)
    {            
        for (int x=0; x&lt;CONSTANT_ARRAY.length; x++)
        {
            System.out.print(CONSTANT_ARRAY[x] + " ");
        }
        System.out.println();
    }
}
</code></pre>

<p>It displays the following output on the console.</p>

<pre><code>I can never change
</code></pre>

<hr>

<p>The following code also goes without any question.</p>

<pre><code>package javaarray;

final public class Main
{
    public static final String[] CONSTANT_ARRAY={"I", "can", "never", "change"};

    public static void main(String[] args)
    {
        //CONSTANT_ARRAY={"I", "can", "never", "change"}; //Error - can not assign to final variable CONSTANT_ARRAY.

        for (int x=0; x&lt;CONSTANT_ARRAY.length; x++)
        {
            System.out.print(CONSTANT_ARRAY[x] + " ");
        }
        System.out.println();
    }
}
</code></pre>

<p>Obviously, the commented line causes the specified error because we are trying to reassign the declared <code>final</code> array of type <code>String</code>.</p>

<hr>

<p>What about the following code.</p>

<pre><code>package javaarray;

final public class Main
{
    public static final String[] CONSTANT_ARRAY={"I", "can", "never", "change"};

    public static void main(String[] args)
    {            
        CONSTANT_ARRAY[2] = "always";  //Compiles fine.
        for (int x=0; x&lt;CONSTANT_ARRAY.length; x++)
        {
            System.out.print(CONSTANT_ARRAY[x] + " ");
        }
        System.out.println();
    }
}
</code></pre>

<p>and it displays <code>I can always change</code> means that we could manage to modify the value of the <code>final</code> array of type <code>String</code>. We can modify the entire array at any time in this way looking like violating the rule of <code>final</code>?</p>
