I have been trying to work with collect method of Stream, to convert list into HashMap. I am using below code as reference :
String result = list.parallelStream().collect(StringBuilder::new,
(response, element) -> response.append(" ").append(element),
(response1, response2) -> response1.append(",").append(response2.toString()))
.toString();
while I write the below incomplete statement in eclipse and do a ctrl+space at ?
Map<String,Choice> map1= list1.stream().collect(()-> new HashMap<String,Choice>(),
(r,s) -> r.?,(r,s) -> r.putAll(s));
considering the code snippet that uses StringBuilder, my expectation was that, the first argument of accumulator function should be a HashMap as I have used HashMap::new as supplier function. As per this understanding, eclipse should suggest me methods of HashMap, but that's not the case.
However, this seems to work fine
list1.stream().collect(ArrayList::new, ArrayList::add, ArrayList::addAll);
Already referred Java 8 Int Stream collect with StringBuilder but, not much luck with this.