This is currently my second day coding in Java, no worries though I am not new to coding. Anyhow, I am not use to not having dictionaries like Python has, which can store a Key and Value.
That is when I came upon Java HashMaps. Currently, I can not seem to get them to work, and I am unsure why. Here is the code I am using, but these seems to be raising errors:
Map<String, String> visual = new HashMap<String, String>();
Then here is the error it is generating:
Multiple markers at this line
- The type Map is not generic; it cannot be parameterized with arguments <String, String>
- HashMap cannot be resolved to a type
I am even importing the Hash libraries:
import java.util.Map;
import java.util.HashMap;
So simply my question is, why is the HashMap not working? Thank you! :)
P.S. Here is my little piece of code:
public Map areaTotal() {
Map<String, String> visual = new HashMap<String, String>();
return visual;
}
EDIT
Sorry, I guess I did forget to include some other information.
You probably have another Map class in the same package which is not generic - this should be removed or renamed to something else
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With