如何在 Java 8 中从列表转换为映射的形式是empID从类内转换,并将值作为对象本身。
List<CompanyEntity> result =
ifEntityManager.createNamedQuery("findByEmployeeId", CompanyEntity.class)
.getResultList();
Map<String, CompanyEntity> result1 = result.stream()
.collect(Collectors.toMap(CompanyEntity::getEmployeeId, CompanyEntity::this)); ??我想要第二个参数作为toMap对象本身。谁能建议如何实现同样的目标?
我尝试这样做Collectors.toMap(CompanyEntity::getEmployeeId, this),但无法摆脱编译错误。
温温酱
摇曳的蔷薇
随时随地看视频慕课网APP
相关分类