Insert Dimensions to complete Expression/ReferenceType

You need to use the wrapper object not the primitive. Use Boolean instead of boolean.


Generic are resolved during compile time and during runtime their no context about the generic used in your code. The Object is than type cast into the class type provided against the generic type. Now both primitive and object are completely unrelated entities in java. Direct time-cast of Object to primitive type isn't possible in java. For this reason the use of primitive type in generic is disallowed and eclipse gives this warning.


Satyendra Sharma's answer is absolutely correct, but here's some reasoning of what exactly the error message is saying.

The error is caused by using a primitive type, which cannot be used as a generic type argument. For instance, List<boolean> is incorrect, whereas List<Boolean> is correct. Wrapper classes can be used to wrap the primitive values and yield a reference type, which can be used with generics.

Insert dimensions? What?

The message "Insert dimensions to complete expression/referenceType" is probably because in order for the expression to become valid, the only valid token here is a set of square brackets.

For instance,

HashMap<Person, boolean[]> marked;

will just compile fine. This is because, unlike a boolean, a boolean[] is an object.


Cause of this error -You are trying to pass a primitive object into a generic type declaration whereas generic types always expect a Wrapper Class object. So please use 'Boolean' instead of 'boolean' in your code i.e. 'B' in caps.