What does "Syntax error, insert Dimensions to complete ReferenceType" mean in Java?

← Java answers

The compiler found a type that looks like an array but is incomplete, such as new String[] without a size or initializer, or a stray [ or . in a declaration. Complete or remove it.

This message comes from the Eclipse compiler (JDT). It appears when the parser expects array dimensions and does not find them.

String[] a = new String[];            // missing size or initializer
String[] b = new String[3];           // size
String[] c = new String[] {"x", "y"}; // initializer
String[] d = {"x", "y"};              // shorthand in a declaration
 
int[][] grid = new int[3][];          // only the first size is required
 
List<String[]> rows = new ArrayList<>();   // an array type as a type argument is fine
  • Look at the line the error marks and the one before it for an unbalanced bracket or parenthesis.
  • Check a method signature such as main(String args[] for a missing closing parenthesis.
  • Primitive types cannot be generic arguments, so List<int> needs List<Integer>.

Related questions

Start debugging smarter today

Try Bugsee for free — no commitments, no hidden fees.

Free sign upLive demoNo credit card required