// "Fix all 'Stream API call chain can be replaced with loop' problems in file" "true" import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; public class Main { void sample(List people) { // comment List list = new ArrayList<>(); for (String person : people) { list.add(person); } List list1 = Collections.unmodifiableList(list); } void sample1(List people) { // comment List list = new ArrayList<>(); for (String person : people) { list.add(person); } List listIdentity = list; } void sample2(List people) { // comment Map result = new HashMap<>(); for (String person : people) { if (result.put(person.length(), person) != null) { throw new IllegalStateException("Duplicate key"); } } Map map = Collections.unmodifiableMap(result); } void sample3(List people) { // comment List strings = new LinkedList<>(); for (String person : people) { strings.add(person); } List result = new ArrayList<>(); for (Iterator it = Stream.concat(strings.stream(), strings.stream()).iterator(); it.hasNext(); ) { String s = it.next(); result.add(s); } List list2 = result; } void sample4(List people) { Map> result = new HashMap<>(); for (String person : people) { result.computeIfAbsent(person.length(), k -> new ArrayList<>()).add(person); } Map> map = Collections.unmodifiableMap(result); } void incomplete(List people) { List list1 = people.stream().collect( // comment Collectors.collectingAndThen(Collectors.toList())); } }