1

I am trying to create a HashMap with one key a string and the other an int. However, my IDE doesn't like it when I try to put an int as a key when creating a HashMap. Here is what I have currently:

private HashMap<String, int> exp = new HashMap<String, int>();

However, my IDE gives errors where I have "int", saying "Syntax error, insert "Dimensions" to complete ReferenceType". But I don't know what that means. So how would I use an int as a key in a HashMap?

1 Answers1

2

int is a primitive type. Use Integer instead.

private HashMap<String, Integer> exp = new HashMap<String, Integer>();
Michael
  • 2,673
  • 1
  • 16
  • 27