List<Account> list1 = new ArrayList<>();
List<Order> list2 = new ArrayList<>();
list1.stream().forEach(l1 -> list2.stream()
.forEach(l2 -> {
if (l1.getOrderId() == l2.getOrderId())
l1.setStatus(l2.getStatus());
}));
I was doing like this. It worked fine but now I have another situation where if orderId is not present in list2 set the status as "invalid" for that particular l1. OrderId is unique in both the tables. Hope this gives better understanding.