I want to add two Map into the third map using lambda expression in java. following is my code. can anyone let me know how to do it.
I want above two maps into third map like Mapurls=repo+data
Please suggest me solution.
I want to add two Map into the third map using lambda expression in java. following is my code. can anyone let me know how to do it.
I want above two maps into third map like Mapurls=repo+data
Please suggest me solution.
Iterating through the key, values for each and adding them to finalMap should work -
Map<String, String> repo = TestRailReader.appendPathToUrl(urlRepo, CoreKeywords.REPO.name());
Map<String, String> data = TestRailReader.appendPathToUrl(urlData, CoreKeywords.DATA.name());
Map<String, String> mergedMap = new HashMap<>();
repo.forEach(mergedMap::put);
data.forEach(mergedMap::put);
Though the solution as suggested by @Emax in comments works better for the case when you need to merge. - Merging two Map<String, Integer> with Java 8 Stream API