Issue
I am trying to convert the list of strings to Map as below but am getting a compilation error no instance(s) of type variable(s) K, T exist so that UUID conforms to Function<? super T, ? extends K>
, can someone please help me with it?
List.of("john","jack", "jill")
.stream()
.collect(Collectors.toMap(UUID.randomUUID(), name ->name));
Solution
Map<UUID, String> collect =
List.of("john", "jack", "jill")
.stream()
.collect(Collectors.toMap(k -> UUID.randomUUID(), name -> name));
Answered By - Qmilogd
Answer Checked By - Mary Flores (JavaFixing Volunteer)