Compiler Error J0264

Array cannot have a dimension

The compiler detected an attempt to initialize an array dimension incorrectly. This error usually occurs when an array dimension size is specified before the instance is created. This error can also occur when an array is given a dimension in the proper place but an initialization list is also provided to set the values of the array (you cannot specify an array size for the dimension when using an initialization list). Correct the initialization of the array specified by the error and compile again.

The following example illustrates this error:

public class Simple{
   public void method1(){
      String[3] var1; /* error: cannot specify array size here since
                         array is not instantiated yet */
      String[] var2 = new String[3]; //this is OK!
      
      boolean var3 = new boolean[3]{true,false,true};
      /*error: cannot specify an array size for the dimension when using
               an initialization list */
      boolean var4 = new boolean[]{true, false,true}; //this is OK!
   }
}