The question title may seem to be same as some other post but the content is different. So please don't mark it duplicate.
Problem:
I have the below class:
public class SCDTO extends RDTO {
private List<String> sCPairs = Collections.emptyList();
public SCDTO(List<String> sCPairs) {
this.sCPairs = sCPairs;
}
//Getter setter
}
I am trying to using the below lambda expression to set the sCPairs.
sCPairsObject.setSCPairs(
util.getSCMap().entrySet().stream()
.filter(entry -> entry.getValue().contains("abc"))
.collect(Collectors.toCollection(ArrayList<String>::new))
);
But I have an compilation error saying:
no instance(s) of type variable(s) exist so that Entry<String, List<String>> conforms to String
util.getSCMap returns Map<String, List<String>>.
Can anyone please explain why this is happening and how to solve it?
Thanks.