I am learning lambda expressions in java. I have the code that uses 'for' loops something like below:
for (RoutingCode routingCode: referencesDao.getRoutingCodes()) {
ReferencesUtil.routingCodeToXml(references.addElement("referenceType"), routingCode);
for (AutoCreateIssue ac: referencesDao.getAutoCreateIssues(routingCode.getId())) {
ReferencesUtil.autoCreateIssueToXml(references.addElement("referenceType"), ac);
}
}
I want to write a lambda expression for the above. I am able to write the lambda expression if there is only one for loop, but not able to do it when there are nested for loops. Any help is appreciated.
This is what I tried with one loop:
referencesDao.getRoutingCodes().stream().forEach(routingCode -> ReferencesUtil.routingCodeToXml(references.addElement("referenceType"), routingCode));
routingCode.getId()from the first loop to the second one.