List<String> strings = Arrays.asList("3","55","3");
Map<String,Integer> map = strings
.stream()
.collect(Collectors.toMap(s ->s, s -> s.length()));
returns
java.lang.IllegalStateException: Duplicate key 1
where I would expect Duplicate key 3