[Solved] How can I define something and save it in HashMap
You can define Ingredients as a class below: import java.util.HashMap; import java.util.Map; import java.util.Set; public class Ingredients { private Map<String, Double> aIngredientTypeToCost = new HashMap<>(); public void put(String theType, Double theCost) { aIngredientTypeToCost.put(theType, theCost); } public Set<String> getAllIngredientsType() { return aIngredientTypeToCost.keySet(); } } then in the main class you can create a map of type … Read more