0

I would like to know why Dimensions are required when using the following code:

Map<char, int> mapacontador = new HashMap <char, int> ();

The error message I get is:

:Syntax error, insert "Dimensions" to complete TypeArgument.

Giulio Caccin
  • 2,962
  • 6
  • 36
  • 57
  • char and int are primitives, whereas HashMap takes object types. Try using Character and Integer instead. – MarsAtomic Feb 18 '21 at 04:45
  • 1
    The map should be declared and initialized like this: `Map mapaContador = new HashMap<>();` - using object types instead of primitives and diamond operator `<>` existing since Java 7 to infer types and thus reduce verbosity in the assignments. – Nowhere Man Feb 18 '21 at 08:43

0 Answers0