3 Replies Latest reply on Apr 12, 2008 9:15 PM by 807601

    Using a static HashMap with a value already put in.

      I tried the following:
      private static Map<String, IngredientType> KNOWN_INGREDIENT_TYPES = new HashMap<String, IngredientType>().put(IngredientType.getNEUTRAL_BASIC_NAME(), IngredientType.getNEUTRAL_TYPE());
      The compiler complains: "Type mismatch: cannot convert from IngredientType to Map<String,IngredientType>"

      However, when I do not put the .put(..), it does not complain. Can I really not use the put method upon constructing the object? If so, is there any other way to construct (not according to the api) the HashMap with already one entry? Any suggestions are welcome.