Is it possible to do the below mentioned steps using streams in a better way ?
Set<Long> memberIds = new HashSet<>();
marksDistribution.parallelStream().forEach(marksDistribution -> {
memberIds.add(marksDistribution.getStudentId());
memberIds.add(marksDistribution.getTeacherId());
});
instanceDistribution.getStudentId() and instanceDistribution.getTeacherId() are both of type Long.
It might be possible that this kind of question is asked but I am not able to understand it. In simple yes or no. If yes/no, then how and bit explanation. And if possible kindly, discuss the efficiency.