I have code like this:
List<Account> myAccounts = new ArrayList<>();
List<String> numbers = new ArrayList<>();
List<Account> resultList = new ArrayList<>();
for (String number : numbers) {
for (Account account : myAccounts) {
if(number.equals(account.getNumber())){
resultList.add(account);
}
}
}
I tried get speciefied accounts with specified numbers, but I do this via loop all numbers and compare to accounts numbers. How can I do this in functional style? Im not asking how to make it into a function, but how to get the same results without having to run two loops every time.
breakin your if to accomplish that.