Declare HashMap (9/13)


#1

Trying this:

import java.util.ArrayList;

public class Restaurant {

    public static void main(String[] args) {
    
    HashMap<String, Integer> restaurantMenu = new HashMap<String, Integer>();

    }
}

Gives me the following errors:

Restaurant.java:7: error: cannot find symbol
HashMap restaurantMenu = new HashMap();
^
symbol: class HashMap
location: class Restaurant
Restaurant.java:7: error: cannot find symbol
HashMap restaurantMenu = new HashMap();
^
symbol: class HashMap
location: class Restaurant
2 errors

What am I doing wrong?


#2
import java.util.HashMap;

public class Restaurant {
	public static void main(String[] args) {
	HashMap<String, Integer> restaurantMenu = new 		HashMap<String, Integer>();
	
	}
}

I don't see the difference but my code did work...


#3

Your #1 line is different from ours

import java.util.HashMap;

mine wasn't working either until I noticed I hadn't capitalized the M in HashMap


#4

Thank you, always the captial letters :grin:


#5