[Solved] Declaration of array size is illegal


A declaration of an array in Java doesn’t require or allow a size specification. This would require to consider int[10] a type, so that, for example, type(int[10]) != type(int[5]). But in Java you can just declare a T[] type without being able to force the size for the declaration.

You just create an array of the specified size during initialization:

boolean[] glCapabilities = new boolean[10];

Specifying the size during the declaration makes sense in a language which requires to know the exact size (like C/C++ in which you can allocate them on stack), but this is not required in Java, since they reside on heap in any case.

1

solved Declaration of array size is illegal