// "Replace Stream API chain with loop" "true" import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; public class Main { public List asList(CharSequence s) { return Collections.singletonList(s); } public List getList() { return Collections.emptyList(); } private void collect() { Map> result = new HashMap<>(); for (CharSequence charSequence : getList()) { if (charSequence != null) { if (result.put(charSequence, asList(charSequence)) != null) { throw new IllegalStateException("Duplicate key"); } } } Map> map = result; System.out.println(map); } }