Trying to create (or rather find out) HashMapbelow:
public class Demo{
public static void main(String args[]){
System.out.println("============Starting Hashmap============");
HashMap<String, Integer> myMap = new HashMap<String, Integer>();
System.out.println("============Ending Hashmap============");
}
}
I use an online compiler and searched a lot, I found that my way of declaring is correct, but something else is causing an error.
Below is the error
Demo.java:8: error: cannot find symbol
HashMap<String, Integer> myMap = new HashMap<String, Integer>();
^
symbol: class HashMap
location: class Demo
Demo.java:8: error: cannot find symbol
HashMap<String, Integer> myMap = new HashMap<String, Integer>();
^
symbol: class HashMap
location: class Demo
2 errors
I need help with: m, just trying to get a basic way to create a hash map and insert some key and value into it, but the above error stopped me in the first step ..... any help in solving this is appreciated! :)
source
share