这UserMst是对象,users也是我从中获取 LoginId && TenantId 的列表。
LinkedHashMap<String, String> Tmap = users.stream().collect(Collectors.toMap(
UserMst::getLoginId, UserMst::getTenantId,
(x, y)-> ((x=="1") ? "Rocks" : (x=="2")
? "Mocks" : (x=="3")
? "Docs" : (x=="4")
? "Pocks" : "")
+ " , " + ( (y=="1") ? "Rocks": (y=="2")
? "Mocks": (y=="3")
? "Docs" : (y=="4")
? "Pocks": ""),
LinkedHashMap::new));
///////////////////
LinkedHashMap<String, String> Tmap =
users.stream().collect(
Collectors.toMap( UserMst::getLoginId, UserMst::getTenantId,
(x, y)-> x + ", " + y, LinkedHashMap::new));
```
It gives output as answer:: …Run Code Online (Sandbox Code Playgroud)