How to match lists of two objects based on a common field using map?

Viewed 23
Class AccountInfo
{
String id;
String name;
String type;
}
Class MeetingsInfo
{
String id;
String count;
Date meetingDate;
}
List<AccountInfo> accounts;
List<MeetingsInfo> meetings;

Here "accounts" contain details of all accounts and meetings contain all meetings of that day. How to create a new list of "AccountInfo" which contain "id" same as the "id" of meetings using "map" function?

I tried to do it this way:

List<AccountInfo> newAccounts = accounts.stream().map(meetings::getAccountId);

Please do mention if there is any optimised method than using map.

1 Answers

create a new list of "AccountInfo" which contain "id" same as the "id" of >meetings

What do want to do if id's are same, merge in a new variable ?

Related