Answer the question
In order to leave comments, you need to log in
`
How to compare two ArrayList`s by their contents?
There are two sheets:
private List rbsList;
private List partnerList;
private List<PaymentRBS> rbsList;
private List<PaymentPartner> partnerList;
public void compare() {
List<PaymentPartner> found = new ArrayList<>();
for (PaymentRBS rbs : rbsList) {
found = partnerList.stream()
.filter(paymentPartner ->
paymentPartner.getAccount().equals(rbs.getAccount()) && paymentPartner.getSum() == rbs.getSum())
.collect(Collectors.toList());
}
found.forEach(System.out::println);
}
Answer the question
In order to leave comments, you need to log in
I would do this:
1. Make a map from both sheets, where the key is the number, accounts, and the value is the object itself.
2. By this key, I would combine both maps into one, but the value would be Tupple2<PaymentRBS, PaymentPartner>
. That. in one tapple there would be both objects with the same account number.
3. According to the values in the final collection, it will be possible to perform all the operations of interest.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question