@Getter
static class Student {
private Map<Status, Marks> statusAndMarks;
}
class Status {
}
class Marks {
}
Map<Status, Student> map = new HashMap<>();
for (Student student : studentList) {
for (Status status : student.getStatusAndMarks().keySet()) {
map.put(status, student);
}
}
How do I write the above written code in functional style in Java 8? I have written the following code but how do I write that the result of my code is an immutable map and I do not need to create a map before the lambda?
studentList
.forEach(student -> {
student
.getStatusAndMarks()
.keySet().stream()
.map(key -> map.put(key, statusKeyImportantMessage));
});