For Loop


#1

Hi There

please assist on the below for loop - my temp variable has been declared as String data type, why is it that when that same variable is called it also prints an incorrect data_type (number)

‘’'
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.size());

	for (String item : restaurantMenu.keySet()) {

		System.out.println("A " + item + " costs " + restaurantMenu.get(item) + " dollars.");

,


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.