So I have an array list:
static List<Integer> KEYS = Arrays.asList(KEY1, KEY2, KEY3);
and I need to create a HashMap<Integer, Double>
whereby the keys are KEYS, and the values are initialized to 0D.
Can I do this in one line of code?
Thx.
By using java-8 stream you can stream the list and collect them into Map
Map<Integer, Double> map = KEYS.stream()
.collect(Collectors.toMap(Function.identity(), i -> 0d));