Error when collecting IntStream to map
问题 The following code String[] values = ... .... Map<String, Object> map = new HashMap<>(); for (int i = 0; i < values.length; i++) { map.put("X" + i, values[i]); } is converted by IntelliJ to: Map<String, Object> map = IntStream.range(0, values.length) .collect(Collectors.toMap( i -> "X" + i, i -> values[i], (a, b) -> b)); which can be shortened to Map<String, Object> map = IntStream.range(0, values.length) .collect(Collectors.toMap( i -> "X" + i, i -> values[i])); The 2 stream versions don't