Compiler Error J0111

Invalid use of array initializer

The compiler detected an attempt to initialize an array, but the initialization statement was not syntactically correct. Arrays can be initialized at declaration with an initial set of values. This error usually occurs when trying to initialize an array of arrays with the incorrect number or positioning of braces and commas. Ensure that the syntax of your array initialization is correct and compile again.

The following example illustrates this error:

public class Simple{
   public void method1(){
      int[]i = {{1,2,3}, {4,5,6}};
      //error: 'i' delcared for only one dimension
   }
}

The following example illustrates the proper syntax for array initialization:

public class Simple{
   public void method1(){
      int[]i = (1,2,3,4,5,6}; //single dimension initialization
      int [][]x = {{1,2,3},{4,5,6}};//multi-dimension initialization
   }
}