I have following enum:
public enum ProductType {
RED_MEAT, POULTRY, FISH, EGGS, NUTS, DAIRY, CERIALS_AND_GRAINS, FRUIT, VEGETABLES, OIL_AND_SUGARS
}
I would like to create map with keys from the enum
and null values. I tried according to this answer following code:
Map<ProductType, DietFrequency> diet = Arrays.stream(ProductType.values())
.collect(Collectors.toMap(productType -> productType, value -> null));
But I am getting NullPointerException
here. What am I doing wrong?