11. HashMap: Access

This post has been reposted in “Data Structures”

I have a headache already trying to figure out what’s wrong with the code. I would really appreciate it SO MUCH if anyone could tell me what’s going on, why am I getting an error when I try this code.

import java.util.HashMap;

public class Restaurant {
public static void main(String[] args) {

HashMap<String, Integer> restaurantMenu = new HashMap<String, Integer>();

restaurantMenu.put("Turkey Burger", 13);
restaurantMenu.put("Naan Pizza", 11);
restaurantMenu.put("Cranberry Kale Salad", 10);

  System.out.println(restaurantMenu.get ("Naan Pizza"));


You made the mistake of putting a space-character between the get AND the opening-paramethesis-(

Remove this space-character so you will get get( )

1 Like