我尝试了这段代码:
final List<ScheduleContainer> scheduleContainers = new ArrayList<>();
scheduleResponseContent.getSchedules().parallelStream().forEach(s -> scheduleContainers.addAll(s));
使用parallelStream时,由于scheduleContainers中的某些条目为空,我会得到ArrayIndexOutOfBoundException或NullpointerException。
使用... .stream()...时一切正常。 我的问题是是否有可能修复这个问题或者我误用了parallelStream?